I record my testcase using katalon automation recoreder, then i export when copy the code to Katalon Studio. when I run the code, i found error
Test Cases/TC-1 FAILED because (of) com.thoughtworks.selenium.SeleniumException: Element //ul[@id=‘menu’]/li[3]/a/span not found
I think it happened beacuse, the page not yet load, but next action is to click something in the page.
I have tried to add implicit wait using selenium
_ driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS)_
but found error like this
Test Cases/TC-1 FAILED because (of) Variable ‘TimeUnit’ is not defined for test case.
use waitElementForClickable for first action after navigateurl if you want your code still run even script didn’t find the object just change failure handling
I have created a fluent wait custom function, based on attribute selection(now css and xpath are supported
import the following libs in the custom function
public class waitfluent {
protected WebDriver driver @Keyword
public void waitForElementvisible(TestObject to, String PropertyValue){
//get the locator value by find it from the testobject
String locator = to.findPropertyValue(PropertyValue)
System.out.println(‘check’ + locator)
driver = DriverFactory.getWebDriver()
FluentWait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(60, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)
.ignoring(WebElementNotFoundException.class)
WebElement element = wait.until(new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
WebElement element
//check if the locator value is css or xpath
if (PropertyValue.equals("css")){
element = driver.findElement(By.cssSelector(locator))
}
else if (PropertyValue.equals("xpath")){
element = driver.findElement(By.xpath(locator))
}
return element
}
})
}
Hi Ralph,
I m looking for exact opposite behavior, wait until element is not found or disappear.
I know I can use selenium invisibilityOfElementLocated method. But in my scenario, an element is not present in DOM. Its get added to DOM runtime on performing any action and once it finishes, it removes that element from DOM.
For Example, on the page there are two buttons, let’s say button1 and button2. On clicking button1, it disables the screen for some time(don’t want to use explicit delay here). So this blocking me to click or select any other elements on the page.