Loop condition until particular text available

Team

need help please.

I want to open page and , i want to click “next” button until the page have “More Languages” text available, then katalon should come out from the loop . i am not sure how to add that. i know how to do loop

example below. can any one add comment here how to set a loop here

WebUI.openBrowser(‘’)
WebUI.navigateToUrl(‘www.bbc.com?’)
30.times({
WebUI.waitForElementClickable(findTestObject(‘Page_Check Out The 25 Most Importan/a_Next’), 2000)
WebUI.click(findTestObject(‘Object Repository/Page_Check Out The 25 Most Importan/a_Next’))
})
WebUI.deleteAllCookies()
WebUI.closeBrowser()

thanks In Advance

Suganthan

If you’re 100% sure that the text will always appear at some point, I would do it in a while loop:

while(true) {
    WebUI.waitForElementClickable(findTestObject(‘Page_Check Out The 25 Most Importan/a_Next’), 2000);
    WebUI.click(findTestObject(‘Object Repository/Page_Check Out The 25 Most Importan/a_Next’));
    if(WebUI.verifyElementPresent(findTestObject('path/to/test/object'), 1, FailureHandling.CONTINUE_ON_FAILURE)) {
        break;
    }
}

Again, I would only use a while loop if you are sure that the text in question will eventually appear. You can do this in a for loop as you’ve suggested, but that presents a problem as well. What if the text appears on the 31’s click? Then your loop of 30 iterations won’t find it.

You will need a new test object that identifies some text node that either matches “More Languages” completely, or contains it. Using xpath, it would look something like:

//*[normalize-space(text())='More Languages']

or

//*[contains(text(), 'More Languages')]