I am trying to test a hybrid app built with Ionic/Cordova on an Android device, writing my tests in Java. When I switch contexts from NATIVE_APP to WEBVIEW_com.company.app, I’m able to access the “html” root element and some sub-elements…but the “body” element is empty. After some poking around, I found that I could use Google Chrome’s chrome://inspector page to see webviews that are running on my Android device. Here’s what I get from that page with my device connected:
It seems that I’m getting the WebView (or context…not really sure what the right terminology is here) with the doubleclick.net URL, rather than the one that’s pointing at index.html. Is there a way in Appium to select the correct item when writing the tests in Java?
Edit: Appium 1.4.0.0 on Windows, Android, real device (Samsung Galaxy S Relay 4G running CyanogenMod 11), writing tests in Java…I think that covers everything that the pinned post requests.
These link shows pages of app which are under webview…
If u click them you can see entire HTML and you can use normal selenium methods to automate it…
When u select HTML element you can see corresponding element highlighted in u r device also
The page you manually open in app will be displayed as a link in chrome inspector and when u click it you can we view its HTML
The question is not “how to do I automate interacting with these pages”, it is “how do I select which page is being interacted with from Appium?” Which is not something that you have addressed.
I am so sorry for what was happened …
But i am still not able to understand ur question???
Like you know how to switch contexts ,how to inspect and automate elements in webview
Appium as such has no role in this inspection it’s a feature provided by chrome browser that’s too only for android version >=KitKat
@Degard Were you able to automate this part… Even I’m Having the Issue. I have 2 Webviews.One is the App view and the other is the Google Sign in Page . Im unable to switch to the Google Page. Please throw some light…
After switching to the webview context, it will be possible switch between the different views that are visible from the Google Chrome inspector tool. You will need to switch between window handles, for example:
@clample:
I have tried the code snippet which you have shared above, Its working fine, But later we need to switch to another page. If i tried the default code driver.switchContext(“WEBVIEW”); is NOT able to switch to the web view.
Log:
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/04f91dc1-ce9b-4c64-8ae7-a2b7cdefcbc8/window] to [POST http://127.0.0.1:8000/wd/hub/session/0b9fe9e9f2e3c94d90de9fb41edf11c3/window] with body: {“name”:“CDwindow-828dc268-2d4f-4e2d-9457-b81a33364c9a”}
[debug] [JSONWP Proxy] Got response with status 200: {“sessionId”:“0b9fe9e9f2e3c94d90de9fb41edf11c3”,“status”:0,“value”:null}
[JSONWP Proxy] Replacing sessionId 0b9fe9e9f2e3c94d90de9fb41edf11c3 with 04f91dc1-ce9b-4c64-8ae7-a2b7cdefcbc8
[HTTP] <-- POST /wd/hub/session/04f91dc1-ce9b-4c64-8ae7-a2b7cdefcbc8/window 200 22 ms - 76
[HTTP] --> POST /wd/hub/session/04f91dc1-ce9b-4c64-8ae7-a2b7cdefcbc8/element {“using”:“id”,“value”:“toggle-0-0”}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/04f91dc1-ce9b-4c64-8ae7-a2b7cdefcbc8/element] to [POST http://127.0.0.1:8000/wd/hub/session/0b9fe9e9f2e3c94d90de9fb41edf11c3/element] with body: {“using”:“id”,“value”:“toggle-0-0”}
[debug] [JSONWP Proxy] Got response with status 200: {“sessionId”:“0b9fe9e9f2e3c94d90de9fb41edf11c3”,“status”:7,“value”:{“message”:“no such element: Unable to locate element: {“method”:“id”,“selector”:“toggle-0-0”}\n (Session info: chrome=61.0.3163.98)\n (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.17134 x86_64)”}}
[JSONWP Proxy] Replacing sessionId 0b9fe9e9f2e3c94d90de9fb41edf11c3 with 04f91dc1-ce9b-4c64-8ae7-a2b7cdefcbc8
[HTTP] <-- POST /wd/hub/session/04f91dc1-ce9b-4c64-8ae7-a2b7cdefcbc8/element 200 107 ms - 339
[HTTP] --> DELETE /wd/hub/session/04f91dc1-ce9b-4c64-8ae7-a2b7cdefcbc8 {}
[debug] [MJSONWP] Calling AppiumDriver.deleteSession() with args: [“04f91dc1-ce9b-4c64-8ae7-a2b7cdefcbc8”]
[debug] [BaseDriver] Event ‘quitSessionRequested’ logged at 1537861449046 (13:14:09 GMT+0530 (India Standard Time))
[Appium] Removing session 04f91dc1-ce9b-4c64-8ae7-a2b7cdefcbc8 from our master session list
[debug] [AndroidDriver] Shutting down Android driver
[debug] [AndroidDriver] Stopping chromedriver for context WEBVIEW_com.hilti.mobile.hiltionline
[debug] [Chromedriver] Changed state to ‘stopping’
[debug] [JSONWP Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8000/wd/hub/session/0b9fe9e9f2e3c94d90de9fb41edf11c3] with no body
[debug] [JSONWP Proxy] Got response with status 200: “{“sessionId”:“0b9fe9e9f2e3c94d90de9fb41edf11c3”,“status”:0,“value”:null}”
[debug] [Chromedriver] Changed state to ‘stopped’
Hi, is there solution to this question of how to automate specific page after switching conext to web view?
Im stuck in this as well.
Thanks in advanced