[英]Checking the prerequisites for an app while clicking an app in home screen
[英]How can I navigate to home screen by clicking home button in appium while automatiing Android app?
在一个测试案例中,我使用了这个
@Test
public void Test1()
{
driver.launchApp();
System.out.println("this is First test in appium suite");
((AppiumDriver) driver).sendKeyEvent(AndroidKeyCode.HOME); // This line of code gives error.
}
到目前为止,如果您正在使用Java客户端的更新版本的appium(3.2.0版),则没有方法可以使用。 您可以使用: driver.runAppInBackground(120); //where time:120 is in seconds
将应用程序在后台保持所需的时间driver.runAppInBackground(120); //where time:120 is in seconds
driver.runAppInBackground(120); //where time:120 is in seconds
driver.findElementByClassName("android.widget.ImageButton").click();
WebDriverWait wait = new WebDriverWait(driver, 1000);
wait.until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
return input.findElement(By.name("Login")) != null;
}
});
driver.navigate().back();
我认为您的代码是正确的driver.sendKeyEvent(AndroidKeyCode.HOME);
必须工作,您可以在driver.launchAPP();
之后尝试超时driver.launchAPP();
方法,因为它可能会尝试在应用程序启动之前打印行并导航到主页。
使用Thread.sleep(5000)
; 在driver.launchAPP();
让我知道它是否有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.