In this scenario, the main page contains a list of links to the subpages. The requirement is to navigate to each page (if a condition passes) and perform some actions.
I have written the loop using Geb:
at MainPage
ListItem.each {
if(Button.present){
Button.click()
at SubPage
SelectAddressButton.click()
termsCheckBox.value(true)
EnterButton.click()
to MainPage
}
}
I feel that the code can be improved so that the toMainPage need not be specified again inside the loop. I have alternatively used driver.navigate().back()
which doesn't seem clean either.