3
\$\begingroup\$

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.

\$\endgroup\$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.