Hybrid Client test broken on upgrade to 1.2.3 due to switch to NATIVE_APP not killing old ChromeDriver

Hi,

We have a Hybrid Client that destroys the webview and recreates it on some page loads. We automated testing around this by switching to the NATIVE_APP and back to the primary webview on these page loads. This worked very well with Appium 1.1.0.

We just upgraded to 1.2.3, and elements can no longer be found after our second round of webview switching. The issue appears to be that ChromeDriver is no longer killed on switching to the NATIVE_APP. This leaves the ChromeDriver around, and it is subsequently reused on the next switch to a new webview.

Here is the Appium 1.1.0 log around our first switch to NATIVE_APP and on to a webview:

debug: Appium request initiated at /wd/hub/session/674f4cc7-e6db-415e-903c-202b113d7982/context
debug: Request received with params: {“name”:“NATIVE_APP”}
info: Getting a list of available webviews
debug: executing: “/Users/johnn/Downloads/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb” -s 090b0c33 shell “cat /proc/net/unix”
info: [“webview_devtools_remote_22439”]
info: Available contexts: NATIVE_APP,WEBVIEW_1
info: Deleting Chrome session
info: Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session/216082d4be27c017435dc954f6c98506",“method”:"DELETE”}
info: Cleaning up Chromedriver
info: Killing chromedriver
info: Chromedriver exited with code null
info: (killed by signal SIGTERM)
info: Responding to client with success: {“status”:0,“value”:null,“sessionId”:“674f4cc7-e6db-415e-903c-202b113d7982”}
POST /wd/hub/session/674f4cc7-e6db-415e-903c-202b113d7982/context 200 31ms - 89b

debug: Appium request initiated at /wd/hub/session/674f4cc7-e6db-415e-903c-202b113d7982/context
debug: Request received with params: {“name”:“WEBVIEW_1”}
info: Getting a list of available webviews
debug: executing: “/Users/johnn/Downloads/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb” -s 090b0c33 shell “cat /proc/net/unix”
info: [“webview_devtools_remote_22439”]
info: Available contexts: NATIVE_APP,WEBVIEW_1
info: Connecting to chrome-backed webview
info: Creating Chrome session
info: Ensuring Chromedriver exists
info: Killing any old chromedrivers, running: ps -e | grep /Users/johnn/Tools/AppiumApp2Contents/Resources/node_modules/appium/build/chromedriver/mac/chromedriver | grep -v grep |grep -e ‘–port=9515$’ | awk ‘{ print $1 }’ | xargs kill -15
info: Successfully cleaned up old chromedrivers
info: Spawning chromedriver with: /Users/johnn/Tools/AppiumApp2Contents/Resources/node_modules/appium/build/chromedriver/mac/chromedriver
info: [CHROMEDRIVER] Starting ChromeDriver (v2.9.248307) on port 9515
info: Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session",“method”:“POST”,“json”:{“sessionId”:null,“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.pega.couriermgmt”,“androidUseRunningApp”:true,“androidDeviceSerial”:"090b0c33”}}}}
info: Could not connect yet; retrying
info: Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session",“method”:“POST”,“json”:{“sessionId”:null,“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.pega.couriermgmt”,“androidUseRunningApp”:true,“androidDeviceSerial”:"090b0c33”}}}}
info: Successfully started chrome session

info: Setting proxy session id to 664760820cc0c2613a0c2877d7eaae4a

Here is the Appium 1.2.3 log, showing the old ChromeDriver being reused. From this point on, we can no longer find any elements in the current page :

info: --> POST /wd/hub/session/a0d2f537-2e8f-45c8-b183-805cf8170282/context {“name”:“NATIVE_APP”}
info: [debug] Getting a list of available webviews
info: [debug] executing: “/Users/johnn/Downloads/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb” -s 090b0c33 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_23397 mapped to pid 23397
info: [debug] Getting process name for webview
info: [debug] executing: “/Users/johnn/Downloads/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb” -s 090b0c33 shell “ps”
info: [debug] Parsed pid: 23397 pkg: com.pega.couriermgmt
info: [debug] from: u0_a124,23397,179,1102432,105048,ffffffff,00000000,R,com.pega.couriermgmt
info: [debug] returning process name: com.pega.couriermgmt
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.pega.couriermgmt
info: [debug] [“WEBVIEW_com.pega.couriermgmt”]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.pega.couriermgmt
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“a0d2f537-2e8f-45c8-b183-805cf8170282”}
info: <-- POST /wd/hub/session/a0d2f537-2e8f-45c8-b183-805cf8170282/context 200 82.571 ms - 76 {“status”:0,“value”:null,“sessionId”:“a0d2f537-2e8f-45c8-b183-805cf8170282”}

info: --> POST /wd/hub/session/a0d2f537-2e8f-45c8-b183-805cf8170282/context {“name”:“WEBVIEW_com.pega.couriermgmt”}
info: [debug] Getting a list of available webviews
info: [debug] executing: “/Users/johnn/Downloads/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb” -s 090b0c33 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_23397 mapped to pid 23397
info: [debug] Getting process name for webview
info: [debug] executing: “/Users/johnn/Downloads/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb” -s 090b0c33 shell “ps”
info: [debug] Parsed pid: 23397 pkg: com.pega.couriermgmt
info: [debug] from: u0_a124,23397,179,1104232,105640,ffffffff,00000000,S,com.pega.couriermgmt
info: [debug] returning process name: com.pega.couriermgmt
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.pega.couriermgmt
info: [debug] [“WEBVIEW_com.pega.couriermgmt”]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.pega.couriermgmt
info: [debug] Connecting to chrome-backed webview
info: [debug] Found existing Chromedriver for context ‘WEBVIEW_com.pega.couriermgmt’. Using it.
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“a0d2f537-2e8f-45c8-b183-805cf8170282”}
info: <-- POST /wd/hub/session/a0d2f537-2e8f-45c8-b183-805cf8170282/context 200 115.876 ms - 76 {“status”:0,“value”:null,“sessionId”:“a0d2f537-2e8f-45c8-b183-805cf8170282”}
info: --> POST /wd/hub/session/a0d2f537-2e8f-45c8-b183-805cf8170282/elements {“using”:“xpath”,“value”:"//div[@class=“document-statetracker” and @data-state-doc-status=“ready” and @data-state-ajax-status=“none”]"}
info: [debug] Proxying command to 127.0.0.1:9515
info: [debug] Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session/5b6e2eb91926872545618968d54174ae/elements",“method”:“POST”,“json”:{“using”:“xpath”,“value”:"//div[@class=“document-statetracker” and @data-state-doc-status=“ready” and @data-state-ajax-status=“none”]”}}
info: [debug] Proxied response received with status 200: {“sessionId”:“5b6e2eb91926872545618968d54174ae”,“status”:0,“value”:[]}
info: <-- POST /wd/hub/session/a0d2f537-2e8f-45c8-b183-805cf8170282/elements 200 571.758 ms - 70
info: --> POST /wd/hub/session/a0d2f537-2e8f-45c8-b183-805cf8170282/elements {“using”:“xpath”,“value”:"//div[@class=“document-statetracker” and @data-state-doc-status=“ready” and @data-state-ajax-status=“none”]"}
info: [debug] Proxying command to 127.0.0.1:9515
info: [debug] Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session/5b6e2eb91926872545618968d54174ae/elements",“method”:“POST”,“json”:{“using”:“xpath”,“value”:"//div[@class=“document-statetracker” and @data-state-doc-status=“ready” and @data-state-ajax-status=“none”]”}}

Any suggestions for a work around or alternative approach would be appreciated

Thanks

1 Like

Looks like a bug. Could you post this as an issue on the github repo?

Thanks!

Posted as item #3775

Thanks