等到屏幕上找到2个元素中的任何一个(Appium)

时间:2017-10-04 03:54:33

标签: appium

我需要在appium中探索wait命令。登录后,可能有2个场景,我希望我的代码等到找到这2个元素中的任何一个。

1 个答案:

答案 0 :(得分:0)

您可以在xpath string

中使用或运算符为这两个定位器使用xpath
  

String xpath =“// * [contains(@text,'登录')   含有(@资源-ID, '/ drawerImgBtn')]“;

Wait waitForElement = new FluentWait(automationDriver.appiumDriver).withTimeout(timeoutInSeconds, TimeUnit.SECONDS).pollingEvery(1, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);
MobileElement element=(MobileElement) waitForElement.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpathString)));
if(element.isDisplayed())
            {

                return true;
            }
            else
            {

                return false;

}