Wait for element to load when testing an iOS app using Appium and Ruby?

后端 未结 4 1319
我在风中等你
我在风中等你 2021-02-06 03:23

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

相关标签:
4条回答
  • 2021-02-06 04:01

    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
    
    0 讨论(0)
  • 2021-02-06 04:03

    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) } }
    
    0 讨论(0)
  • 2021-02-06 04:07

    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));
    }
    
    0 讨论(0)
  • 2021-02-06 04:15

    I use this solutions in appium java:

    • Thread.sleep(1000);

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

    0 讨论(0)
提交回复
热议问题