Appium pointing to stale data

Hi,

I have a hybrid Android app (which has both Native and Webview contexts).
On clicking on a button in Webview on page1, the app move to page page2 which is also a webview.
However, on clicking on the button, Appium still holds reference to page1 elements and fails when I try to do any operation on the page2 elements. I did a getPageSource to get the elements that Appium was pointing to and found out that it is still pointing to page1 elements even when we have moved to page2.

Not being able to debug this scenario and would appreciate any leads.

Appium log Please :smile:

1 Like

info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /Users/neha.goyal/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_7778 mapped to pid 7778
info: [debug] Getting process name for webview
info: [debug] executing cmd: /Users/neha.goyal/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “ps”
info: [debug] Parsed pid: 7778 pkg: com.flipkart.android
info: [debug] from: u0_a57,7778,945,900304,178416,ffffffff,b76d3d52,R,com.flipkart.android
info: [debug] returning process name: com.flipkart.android
info: [debug] Available contexts:
info: [debug] [“WEBVIEW_com.flipkart.android”]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.flipkart.android
info: [debug] Responding to client with success: {“status”:0,“value”:[“NATIVE_APP”,“WEBVIEW_com.flipkart.android”],“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/contexts 200 186.367 ms - 117 {“status”:0,“value”:[“NATIVE_APP”,“WEBVIEW_com.flipkart.android”],“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context {}
info: [debug] Responding to client with success: {“status”:0,“value”:“NATIVE_APP”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context 200 1.073 ms - 84 {“status”:0,“value”:“NATIVE_APP”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context {“name”:“WEBVIEW_com.flipkart.android”}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /Users/neha.goyal/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_7778 mapped to pid 7778
info: [debug] Getting process name for webview
info: [debug] executing cmd: /Users/neha.goyal/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “ps”
info: [debug] Parsed pid: 7778 pkg: com.flipkart.android
info: [debug] from: u0_a57,7778,945,900304,178268,ffffffff,b7735565,S,com.flipkart.android
info: [debug] returning process name: com.flipkart.android
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.flipkart.android
info: [debug] [“WEBVIEW_com.flipkart.android”]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.flipkart.android
info: [debug] Connecting to chrome-backed webview
info: Chromedriver: Changed state to ‘starting’
info: Chromedriver: Set chromedriver binary as: /Users/neha.goyal/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver
info: Chromedriver: Killing any old chromedrivers, running: ps -ef | grep /Users/neha.goyal/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver | grep -v grep |grep -e ‘–port=9515(\s.*)?$’ | awk ‘{ print $2 }’ | xargs kill -15
info: Chromedriver: Successfully cleaned up old chromedrivers
info: Chromedriver: Spawning chromedriver with: /Users/neha.goyal/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver --url-base=wd/hub --port=9515
info: Chromedriver: [STDOUT] Starting ChromeDriver 2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281) on port 9515
Only local connections are allowed.
info: JSONWP Proxy: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: JSONWP Proxy: Got response with status 200: {“sessionId”:"",“status”:0,“value”:{“build”:{“version”:“alpha”},“os”:{“arch”:“x86_64”,“name”:“Mac OS X”,“version”:“10.10.4”}}}
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.flipkart.android”,“androidUseRunningApp”:true,“androidDeviceSerial”:“emulator-5554”}}}
info: JSONWP Proxy: Got response with status 200: {“sessionId”:“7bb9e9910a421fb368f712579cb8e185”,“status”:0,“value”:{“acceptSslCerts”:true,“applicationCacheEnabled”:false,“browserConnectionEnabled”:false,“browserName”:“chrome”,“chrome”:{},"cssSelect…
info: Chromedriver: Changed state to ‘online’
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context 200 919.627 ms - 76 {“status”:0,“value”:null,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context {}
info: [debug] Responding to client with success: {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context 200 1.853 ms - 102 {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context {}
info: [debug] Responding to client with success: {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context 200 2.341 ms - 102 {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/element {“using”:“class name”,“value”:“t3Y2k6c1XvPpK-F0WB2aF”}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/element] to [POST http://127.0.0.1:9515/wd/hub/session/7bb9e9910a421fb368f712579cb8e185/element] with body: {“using”:“class name”,“value”:“t3Y2k6c1XvPpK-F0WB2aF”}
info: JSONWP Proxy: Got response with status 200: {“sessionId”:“7bb9e9910a421fb368f712579cb8e185”,“status”:0,“value”:{“ELEMENT”:“0.333962825126946-1”}}
info: JSONWP Proxy: Replacing sessionId 7bb9e9910a421fb368f712579cb8e185 with 50cc1025-ab57-47f9-abdf-0c0c3fd8f894
info: <-- POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/element 200 1081.340 ms - 105
info: --> POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/element/0.333962825126946-1/click {“id”:“0.333962825126946-1”}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/element/0.333962825126946-1/click] to [POST http://127.0.0.1:9515/wd/hub/session/7bb9e9910a421fb368f712579cb8e185/element/0.333962825126946-1/click] with body: {“id”:“0.333962825126946-1”}
info: JSONWP Proxy: Got response with status 200: {“sessionId”:“7bb9e9910a421fb368f712579cb8e185”,“status”:0,“value”:null}
info: JSONWP Proxy: Replacing sessionId 7bb9e9910a421fb368f712579cb8e185 with 50cc1025-ab57-47f9-abdf-0c0c3fd8f894
info: <-- POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/element/0.333962825126946-1/click 200 1160.641 ms - 76
info: --> GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/contexts {}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /Users/neha.goyal/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_7778 mapped to pid 7778
info: [debug] Getting process name for webview
info: [debug] executing cmd: /Users/neha.goyal/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “ps”
info: [debug] Parsed pid: 7778 pkg: com.flipkart.android
info: [debug] from: u0_a57,7778,945,904576,176552,ffffffff,b7735565,S,com.flipkart.android
info: [debug] returning process name: com.flipkart.android
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.flipkart.android
info: [debug] [“WEBVIEW_com.flipkart.android”]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.flipkart.android
info: [debug] Responding to client with success: {“status”:0,“value”:[“NATIVE_APP”,“WEBVIEW_com.flipkart.android”],“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/contexts 200 80.978 ms - 117 {“status”:0,“value”:[“NATIVE_APP”,“WEBVIEW_com.flipkart.android”],“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context {}
info: [debug] Responding to client with success: {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context 200 0.776 ms - 102 {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context {}
info: [debug] Responding to client with success: {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context 200 0.929 ms - 102 {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context {}
info: [debug] Responding to client with success: {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context 200 0.898 ms - 102 {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/element {“using”:“class name”,“value”:“form-label”}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/element] to [POST http://127.0.0.1:9515/wd/hub/session/7bb9e9910a421fb368f712579cb8e185/element] with body: {“using”:“class name”,“value”:“form-label”}
info: JSONWP Proxy: Got response with status 200: {“sessionId”:“7bb9e9910a421fb368f712579cb8e185”,“status”:7,“value”:{“message”:"no such element: Unable to locate element: {“method”:“class name”,“selector”:“form-label”}\n (Session info: webv…
info: JSONWP Proxy: Replacing sessionId 7bb9e9910a421fb368f712579cb8e185 with 50cc1025-ab57-47f9-abdf-0c0c3fd8f894
info: <-- POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/element 200 59.980 ms - 339
info: --> GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/contexts {}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /Users/neha.goyal/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_7778 mapped to pid 7778
info: [debug] Getting process name for webview
info: [debug] executing cmd: /Users/neha.goyal/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “ps”
info: [debug] Parsed pid: 7778 pkg: com.flipkart.android
info: [debug] from: u0_a57,7778,945,904576,177352,ffffffff,72f46667,R,com.flipkart.android
info: [debug] returning process name: com.flipkart.android
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.flipkart.android
info: [debug] [“WEBVIEW_com.flipkart.android”]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.flipkart.android
info: [debug] Responding to client with success: {“status”:0,“value”:[“NATIVE_APP”,“WEBVIEW_com.flipkart.android”],“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/contexts 200 110.131 ms - 117 {“status”:0,“value”:[“NATIVE_APP”,“WEBVIEW_com.flipkart.android”],“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context {}
info: [debug] Responding to client with success: {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: <-- GET /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context 200 3.139 ms - 102 {“status”:0,“value”:“WEBVIEW_com.flipkart.android”,“sessionId”:“50cc1025-ab57-47f9-abdf-0c0c3fd8f894”}
info: --> POST /wd/hub/session/50cc1025-ab57-47f9-abdf-0c0c3fd8f894/context {“name”:“NATIVE_APP”}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: /Users/neha.goyal/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_7778 mapped to pid 7778
info: [debug] Getting process name for webview
info: [debug] executing cmd: /Users/neha.goyal/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell “ps”
info: [debug] Parsed pid: 7778 pkg: com.flipkart.android
info: [debug] from: u0_a57,7778,945,904576,177380,ffffffff,b6a2ef7b,R,com.flipkart.android
info: [debug] returning process name: com.flipkart.android
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.flipkart.android
info: [debug] [“WEBVIEW_com.flipkart.android”]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.flipkart.android

Another thing that I have noticed and might help us in debugging is that when I do google inspect, sometimes I see 3/4 webviews out of which only 1 is attached, rest is detached. Attaching screenshot. Is it possible that Appium is holding on to the webview which is detached??

ping to @jlipps or @isaac on this one.

Hey…i’m also facing the same issue, when i;m trying to convert to webview in one page and tries to convert to webview again in another page, its pointing to stale data…Please help @Neha_Goyal @jonahss

Can anyone please help us with the relevant solution @jlipps @isaac