How can I click on a element while another element is not present

Hi,

Thanks for your FB!

I tried this solution yesterday but it failed as when it looks for an element that is not on the current page but the next page, Katalon shows an error because it can’t find element to verify if it exists:

Unable to verify object ‘link’ is present (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘link’ located by ‘By.xpath: …’ not found)

My sample script:

for (int i = 1; i<=20;i++){
link = new TestObject(“link”)
link.addProperty(“xpath”, ConditionType.EQUALS,“//div[@class='a”+i+“']”, true)
if(WebUiBuiltInKeywords.verifyElementPresent(link, 10) == true){
WebUiBuiltInKeywords.scrollToElement(link, 3)
WebUiBuiltInKeywords.click(link, FailureHandling.STOP_ON_FAILURE)
WebUiBuiltInKeywords.delay(1)
}
else{
WebUiBuiltInKeywords.callTestCase(TestCaseFactory.findTestCase(‘Test Cases/GoNext’), [:],FailureHandling.STOP_ON_FAILURE)
}

}