如何"等到活动"使用appium,就开始和测试本身期间? [英] how to "wait to activity" using appium, on begin and during test itself?
问题描述
我使用appium启动已经安装的应用程序。
I'm starting an already installed app using appium.
在我的驱动程序进行初始化。我该如何使民意调查,等到显示一定的活动?
after my driver is initialized. How do I make it poll-wait till certain activity is displayed?
我在启动时只看到了这样的方式来等待活动
I saw only this way to wait for activity when starting up
cap.setCapability(应用程序 - 等待 - 活动,活动到等待换);
还有没有其他的办法吗?我如何等待另一个特定活动时,不进行初始化。之后,点击一个按钮说?
is there any other way? How do I wait to another specific activity when not initializing. Say after a button click?
只是睡眠x秒
?
推荐答案
比活度是指在显示某些特定的元素。 我用下面的code等到屏幕上的一些特定元素:
Specific activity means some specific element is being displayed. I use the following code to wait until some certain element on the screen:
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.elementToBeClickable(By
.xpath("//android.widget.Button[contains(@text, 'Log In')]")));
或
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.presenceOfElementLocated(By
.xpath("//android.widget.TextView[contains(@resource-id, 'action_bar_title')]")));
这篇关于如何"等到活动"使用appium,就开始和测试本身期间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!