I need to wait in the middle of my test for 5 minutes but the Appium session has default newCommandTimeout of 60s. and I get exception in the next command that my session is timeout.
AndroidDriver appiumDriver = new AndroidDriver(new URL(getMcmUrl()), capabilities);
Thread.sleep(5*60*1000); // 5 minutes sleep time
appiumDriver.executeScript("...")
newCommandTimeout:
How long (in seconds) Appium will wait for a new command from the client before assuming the client quit and ending the session
in case that the timeout is 60s, you need to execute any command at least once in a minute, to keep the session alive.
For example, this is how sleep for 5 minutes should look like
for (int i = 0; i < 5; i++) {
driver.getOrientation(); // execute some command to keep the session alive
Thread.sleep(59*1000); // wake up before session expired
}
Read this article for more information
https://l18.me/how-to-keep-alive-appium-driver-da9227b2fa