Wait for element to load when testing an iOS app u

2020-05-28 01:18发布

问题:

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 WebDriverWait style of waiting for Appium iOS testing? Preferably in Ruby.

Thanks.

回答1:

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


回答2:

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) } }


回答3:

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));
}


回答4:

I use this solutions in appium java:

  • Thread.sleep(1000);

  • WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.elementToBeClickable(By.name("somename")));



标签: ios ruby appium