Vinay

About

Username
Vinay
Joined
Visits
49
Last Active
Roles
Members, Staff
Points
14
Posts
7
Badges
2
  • Re: Run a particular test in the suite multiple times

    Just want to clarify, looping/Test Suite flow logic is defined at "Test Suite" or "Test Scenario" level not at test level. So if you have specific test to run n-times, I would suggest to add that test in separate test-suite/scenario and apply above solution recommended by OmarR.
    After changes, your test suite would look something like this:
    Test Suite: test1, Test Suite2 -> test2, test3. You need to set the "Test Suite Flow Logic" at Test Suite2.

  • Re: How to assert the length of the field.

    Besides what previous post suggested and explained, you can try something like this:
    Let's say I have a payload that returns array of username and password, and I want to make sure password length is exactly 8 characters for each user.
    Payload:
    {
    "users": [
    {"username" : "admin1",
    "password" : "password"},
    {"username" : "admin",
    "password" : "password2"},
    {"username" : "admin3",
    "password" : "pass"}
    ]
    }

    Solution:
    I would do chain JSON Value assertion -> Custom Assertion to my response traffic, and script (Groovy):
    def enforcePasswordLength(input){
    return input.length() == 8
    }
    And set the element locator as: "/root/users/item/password/text()"

    Test fails, and indicate an error on which element failed the condition. Something like this for above payload:

    Error Message:
    Custom Assertion: Method "enforcePasswordLength" returned false when asserting on 2nd element of
    ../password.. (Note that this assertion is commonly used to extract an entire element but it has
    currently been configured to extract the content only. Please double check if the extract
    configuration is correct.)

    Custom Assertion: Method "enforcePasswordLength" returned false when asserting on 3rd element of
    ../password.. (Note that this assertion is commonly used to extract an entire element but it has
    currently been configured to extract the content only. Please double check if the extract
    configuration is correct.)