使用Appium和RubytestingiOS应用程序时是否需要加载元素?

我正在testing一个iOS应用程序,并且不能与login后的元素交互,因为Appium速度太快了。

有人可以请我指出一个使用WebDriverWait风格等待Appium iOStesting的例子吗? 最好在Ruby中。

谢谢。

这工作对我来说,但我是新来的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 

这是我想出来的,但在java中。 有点抽出来,但它会引导你如何等待。 它会花几秒钟的等待时间,然后检查每一秒,看看元素是否存在。 一旦find元素,就确定它是可见的,因此可以与之交互。 “驱动程序”显然是WebDriver对象。

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

我使用这个构造等待一些元素出现:

 wait_true { exists { find_element(:xpath, path_to_element) } } 

当然,你不仅可以通过:xpathfind。

你也可以设置超时时间:

 wait_true(timeout) { exists { find_element(:xpath, path_to_element) } } 

我在appium java中使用这个解决scheme:

  • Thread.sleep(1000);

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