How can we continue the session in appium before it expires?

Facing an issue where it throws error “SessionTimeOut”.

Before I can store the current session but dont know how we can use?

@jonahss @willosser Any idea?

Can you provide the logs?

@bhaskar: Can you please share an example with code if possible?

@willosser: Please find the logs as below:

info: → POST /wd/hub/session/39e100c9-fe49-400d-8c15-6507eddc372a/touch/perform {“actions”:[{“action”:“press”,“options”:{“element”:“17”}},{“action”:“wait”,“options”:{“ms”:60000}}]}
info: [debug] Pushing command to appium work queue: [“element:touchDown”,{“elementId”:“17”}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:touchDown”,“params”:{“elementId”:“17”}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: touchDown
info: [debug] [BOOTSTRAP] [debug] Performing TouchDown using element? true x: 652, y: 638
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:true,“status”:0}
info: [debug] Didn’t get a new command in 60 secs, shutting down…
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: D:\softwareSetups\Android\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe -s 3204da2a5075c0b5 shell “input keyevent 3”
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“shutdown”}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“OK, shutting down”,“status”:0}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 163.84
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
info: [debug] Responding to client with success: {“status”:0,“value”:true}
info: ← POST /wd/hub/session/39e100c9-fe49-400d-8c15-6507eddc372a/touch/perform 200 60849.067 ms - 25 {“status”:0,“value”:true}
info: → POST /wd/hub/session/39e100c9-fe49-400d-8c15-6507eddc372a/touch/perform {“actions”:[{“action”:“press”,“options”:{“element”:“17”}},{“action”:“wait”,“options”:{“ms”:180000}},{“action”:“moveTo”,“options”:{“element”:“18”}},{“action”:“release”,“options”:{}}]}
info: ← POST /wd/hub/session/39e100c9-fe49-400d-8c15-6507eddc372a/touch/perform 404 1.401 ms - 40
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] We shut down because no new commands came in
info: → DELETE /wd/hub/session/39e100c9-fe49-400d-8c15-6507eddc372a {}
info: ← DELETE /wd/hub/session/39e100c9-fe49-400d-8c15-6507eddc372a 404 1.356 ms - 40

The problem, as you no doubt noticed, is here:

info: [debug] [BOOTSTRAP] [debug] Performing TouchDown using element? true x: 652, y: 638
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Didn't get a new command in 60 secs, shutting down...

Based on your comments above, I’m assuming this is failing during startup. One of the reasons this may be failing is if it is looking for appActivity and it’s not displayed. Have you set this capability when starting up the server?

As an aside, I always start my server with --logtimestamp so the appium logs have timestamps embedded.

But, what if I want to debug my test code and set up a debugger. Can you please provide an insight to increase the wait time instead of 60 sec.

http://appium.io/slate/en/master/?ruby#server-flags -> --command-timeout