Always taking screenshots not working, please shed some lights

86 views
Skip to first unread message

Arisa Ando

unread,
Sep 6, 2018, 9:20:24 AM9/6/18
to qaf users
Hi

This is Ando from Japan. Currently we are using QAF to automate our tests, I have to say, QAF is so far the best selenium framework I have ever used.

Today I encountered one problem, we are required to take screenshots as evidences no matter a check point fails or not. So I set selenium.success.screenshots=1 in the application.properties file. However it does not work, it still only took screenshots when checkpoints failed. Did I miss anything here? Please shed some lights on how to solve this issue.

Much appreciated!

cjayswal

unread,
Sep 6, 2018, 3:10:52 PM9/6/18
to qaf-...@googlegroups.com
Will you please share your test case code/bdd? does it have any checkpoints?

Refer documentation on different sections in report. If you are able to see screenshot icon in report with checkpoint message, you can try right click and open on screenshot icon.  When you run your test through ide as testng test you may observe this behavior.

selenium.success.screenshots=1 is setting of screenshot behavior for checkpoint (assertion/verification). So if you have any assertion and/or verification which is called as checkpoint, in your test it should capture screenshot for checkpoint. If you set selenium.success.screenshots to 0 or false then you will get screenshot only for failures and not for success.


गुरुवार, 6 सितंबर 2018 को 6:20:24 पूर्व UTC-7 को, Arisa Ando ने लिखा:

Arisa Ando

unread,
Sep 7, 2018, 9:03:52 AM9/7/18
to qaf users
Hi Chirag

Thanks for the reply!

Let me share more information in our case.

We are using the latest version of QAF (2.1.13), basically following the Starter Kit settings.
One scenario is like this:

 Scenario: Verify xxx Links
    Given a user is logged in with email "xxx and password "yyy", and on the landing page
    Then the user should see the link "http://aa.com/consulting"
      And the user should see the product link "http://aa.com/products"

The implementation is something like:
   @Then("^the user should see the link \"([^\"]*)\"$")
    public void theUserShouldSeeTheLink(String link) throws Throwable {
        Assert.assertEquals(new LandingPage().getLink(), link);
    }

    @And("^the user should see the products link \"([^\"]*)\"$")
    public void theUserShouldSeeTheProductsLink(String link) throws Throwable {
        Assert.assertEquals(new LandingPage().getLeadsProductLink(), link);
    }

We use TestNG Assert so I think they are check points, right? However, even I set selenium.success.screenshots=1, there are no screenshots captured (neither there are screenshot icons in the report nor there are images file under /img folder). I tried to debug into it, it seems the takeScreenshot method never called for a succeeded test case. Did I miss anything?

By the way, how to use AssertService class in QAF, isn't TestNG Assert enough for verification?

Again I appreciate your support on this!

Warm regards
Ando

cjayswal

unread,
Sep 7, 2018, 11:03:50 AM9/7/18
to qaf-...@googlegroups.com
Testng assert will neither report nor capture screenshot for success. Refer documentation https://qmetry.github.io/qaf/latest/tag_checkpoint.html

For your case you can use inbuilt step from qaf-support.

assert link with text {linkText} is present
assert link with partial text {linkText} is present
verify link with text {linkText} is present
verify link with partial text {linkText} is present

Or use validator:


@Then("^the user should see the link \"([^\"]*)\"$")
    public void theUserShouldSeeTheLink(String link) throws Throwable {
       // Assert.assertEquals(new LandingPage().getLink(), link);

Validator.assertThat(new LandingPage().getLink(),Matchers.equalTo(link));
//or
//Validator
.verifyThat(actual,Matchers.equalTo(expected));
or
    }

Ideally if you are creating test page then page should return element rather then text or value.

for example "getLink()" should return element instead of string so you can do required operations/validations on it for example:

QAFWebElement link = landingPageObj.getLink();

validations:
link.verifyText("First User");
link.assertText("First User");
link.verifyText(StringMatcher.contains("First User"));
link.assertText(StringMatcher.contains("First User"),"Username Validation");

actions:
link.click();
and so on...


Arisa Ando

unread,
Sep 7, 2018, 12:03:47 PM9/7/18
to qaf users
Oh now I see the cause. Thanks a lot!

On Saturday, September 8, 2018 at 12:03:50 AM UTC+9, cjayswal wrote:
Testng asset will neither report nor capture screenshot for success. Refer documentation https://qmetry.github.io/qaf/latest/tag_checkpoint.html
Reply all
Reply to author
Forward
0 new messages