How to do a order based testing in Geb and Spock using Groovy, I want to verify if the given values are in order from UI

33 Views Asked by At

I am using Geb and Spock with Groovy and got stuck on testing with order and need to verify from UI.

Ex- I have 5 values which i need to get the texts from UI and compare whether they are matching from my groovy file

Groovy class with test step- and:

_ "I verify for the values is displayed as per the order"
baseclass.verifyOrder(["a", "b", "c", "d", "e"])

base file-

void verifyOrder(List<String> Order){
  for(String check:Order){
    locator.displayed
    String st = locator.text()
    assert check == st
  }
}

From above I am getting the result as true even though I changed order of the list (Ex- b replace a).

What i want is when the order is not correct it should fail and give pass when it is in correct order from UI. Can someone help me on this do i need check the locator or am I missing any logic in code. Thanks in advance!

0

There are 0 best solutions below