Appium Timeout preventing test to complete

For testing native android app with Android Studio emulator+Python+Appium,
my application is getting closed before my test code finishes running.

Appium log show:
[BaseDriver]e[39m Shutting down because we waited 60 seconds for a command
[Appium]e[39m Closing session, cause was ‘New Command Timeout of 60 seconds expired. Try customizing the timeout using the ‘newCommandTimeout’ desired capability’

I have tried to override this 60secs multiple ways when setting capabilities:

desired_caps = dict(
newCommandTimeout=180000, #in milliseconds
commandTimeout=180000, #in milliseconds
idleTimeout=600, #in seconds
endSessionWaitTimeout=600 #in seconds

also have

also introduced handling of stale element like:
def handle_stale_element (driver, locator):
return WebDriverWait(driver, 30).until(EC.visibility_of_element_located(locator))
except StaleElementReferenceException:
# Element reference is stale, retry finding the element
return WebDriverWait(driver, 30).until(EC.visibility_of_element_located(locator))

but issue still not resolved.

Anybody can offer hints?

this is SERVER setting → Server Command-Line Arguments - Appium Documentation

appium --keep-alive-timeout 180
1 Like