如何“等待活动"在开始和测试期间使用 Appium? [英] How to "wait to activity" using Appium, on begin and during test itself?

查看:25
本文介绍了如何“等待活动"在开始和测试期间使用 Appium?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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("app-wait-activity", "activity-to-wait-for");

还有别的办法吗?未初始化时如何等待另一个特定活动.点击按钮后说?

Is there any other way? How do I wait to another specific activity when not initializing. Say after a button click?

只是 sleep x seconds 吗?

推荐答案

特定活动意味着正在显示某些特定元素.我使用以下代码等待屏幕上的某些元素:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆