I am testing an iOS app, and can\'t interact with the elements after logging in because Appium is going too fast.
Can someone please point me to an example of using a We
This worked for me but I am new to Appium
#code that navigated to this page
wait = Selenium::WebDriver::Wait.new :timeout => 10
wait.until { @driver.find_element(:name, 'myElementName').displayed? }
#code that deals with myElementName
I use this construction to wait some element appears:
wait_true { exists { find_element(:xpath, path_to_element) } }
Of course, you can find not only by :xpath
.
Also you can set timeout:
wait_true(timeout) { exists { find_element(:xpath, path_to_element) } }
Here is the one I came up with, but in java. A little drawn out but it walks you through how it should wait. It will take in a wait time in seconds and then check every second to see if the element is present yet. Once it has located the element it makes sure that it is visible so it can be interacted with. "driver" is obviously the WebDriver object.
public void waitForVisible(final By by, int waitTime) {
wait = new WebDriverWait(driver, timeoutInSeconds);
for (int attempt = 0; attempt < waitTime; attempt++) {
try {
driver.findElement(by);
break;
} catch (Exception e) {
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
}
}
wait.until(ExpectedConditions.visibilityOfElementLocated(by));
}
I use this solutions in appium java:
Thread.sleep(1000);
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.elementToBeClickable(By.name("somename")));