在一个测试用例中,我使用了这个
@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.
}
答案 0 :(得分:1)
到目前为止,如果您使用java客户端的更新版本(版本3.2.0),则没有方法可以回家。
您可以使用以下方法将应用程序保留在后台,但需要达到所需的时间:
driver.runAppInBackground(120); //where time:120 is in seconds
答案 1 :(得分:1)
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();
答案 2 :(得分:0)
我认为您的代码是正确的[2015-09-08 11:38:37 - Raftaar_Jyotish] D:\Gaurav\Work\v7\appcompat\res\values-v21\themes_base.xml:137: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
[2015-09-08 11:38:37 - Raftaar_Jyotish]
[2015-09-08 11:38:37 - Raftaar_Jyotish] D:\Gaurav\Work\v7\appcompat\res\values-v21\themes_base.xml:134: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
[2015-09-08 11:38:37 - Raftaar_Jyotish]
[2015-09-08 11:38:37 - Raftaar_Jyotish] D:\Gaurav\Work\v7\appcompat\res\values-v21\themes_base.xml:135: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.
[2015-09-08 11:38:37 - Raftaar_Jyotish]
[2015-09-08 11:38:37 - Raftaar_Jyotish] D:\Gaurav\Work\v7\appcompat\res\values-v21\themes_base.xml:144: error: Error: No resource found that matches the given name: attr 'android:windowElevation'.
[2015-09-08 11:38:37 - Raftaar_Jyotish]
[2015-09-08 11:38:37 - Raftaar_Jyotish] D:\Gaurav\Work\v7\appcompat\res\values-v21\themes_base.xml:148: error: Error: No resource found that matches the given name: attr 'android:windowElevation'.
[2015-09-08 11:38:37 - Raftaar_Jyotish] ............
必须正常工作,您可以尝试在driver.sendKeyEvent(AndroidKeyCode.HOME);
方法之后暂停,因为它可能会尝试在应用启动之前打印Line并导航到Home。
使用driver.launchAPP();
;在Thread.sleep(5000)
之后让我知道它是否有效。