Reputation: 6092
I am using appium, nodejs to write automated test case for android. I need to know how to wait until a element is clickable. I am using wd nodejs web driver library.
Upvotes: 4
Views: 6538
Reputation: 518
var asserters = wd.asserters;
return driver.waitForElementById(id, asserters.isDisplayed, 10000, 100)
then(function(el){
return el.click())
The above function waits for an element to be displayed for 10 seconds pinging every 100ms and once isDisplayed returns true it clicks on the element.
Upvotes: 1
Reputation: 595
In Java it would be following:
import org.openqa.selenium.support.ui.WebDriverWait
import org.openqa.selenium.support.ui.ExpectedCondition
import static org.openqa.selenium.support.ui.ExpectedConditions.*
import static org.joda.time.Duration.standardSeconds
void click(By by) {
waitUntil(elementToBeClickable(by),standardSeconds(25))
findElement(by).click()
}
void waitUntil(ExpectedCondition<?> until, Duration duration) {
WebDriverWait wait = new WebDriverWait(driver(), duration.getStandardSeconds())
wait.until(until)
}
Upvotes: 0