Reputation: 546
In one test cases I used this
@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.
}
Upvotes: 1
Views: 5856
Reputation: 31878
Well as of now if you are using the updated version of the java client for appium (ver 3.2.0), there is no method to go home.
You can keep the app in background though for the desired amount of time using :
driver.runAppInBackground(120); //where time:120 is in seconds
Upvotes: 1
Reputation: 23
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();
Upvotes: 1
Reputation: 785
I think your code is correct driver.sendKeyEvent(AndroidKeyCode.HOME);
Must work, You can try to give some timeout after driver.launchAPP();
method because It might try to print the Line and navigate to Home before app launch.
Use Thread.sleep(5000)
; After the driver.launchAPP();
Let me know if it works.
Upvotes: 0