iOS: Wrong Context Selected When App Has Multiple WebViews
See original GitHub issueThe problem
In some of our use cases we test apps with multiple webviews in a single screen, and it appears that in some cases attempting to select a context before the second webview is loaded causes the wrong one to be selected.
Reproduced on iOS 11.0.3, 12.4 and 13.3.1 (with an additional getContextHandles() call before loading the first page to work around https://github.com/appium/appium/issues/13770).
Attempting to set the context again to the same one immediately after the incorrect one has been selected causes the correct one to be selected.
Environment
- Appium version (or git revision) that exhibits the issue: 1.16.0
- Last Appium version that did not exhibit the issue (if applicable): N/A
- Desktop OS/version used to run Appium: MacOS 10.14.6
- Node.js version (unless using Appium.app|exe): v10.15
- Npm or Yarn package manager: npm
- Mobile platform/version under test: iOS
- Real device or emulator/simulator: Real Device
- Appium CLI or Appium.app|exe: CLI
Link to Appium logs and code to reproduce
https://gist.github.com/Dan-Maor/fea2f29fe030f62795498e36e023ad04
(the script fails when attempting to find //div
in the first webview, sometimes it fails to recognize the first webview at all.
Sample app:
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Unable to select WebView element after switching context in ...
Turns out that I had multiple WebViews in my app and I had to switch context to the right one. The trick is...
Read more >Adding Context Menus in Your App - Apple Developer
This sample project demonstrates how to add context menus to user-interface elements such as views, controls, table views, collection views, and web views....
Read more >WKWebView | Apple Developer Documentation
An object that displays interactive web content, such as for an in-app browser.
Read more >Web views - Human Interface Guidelines - Apple Developer
Using a web view to let people briefly access a website without leaving the context of your app is fine, but Safari is...
Read more >WebView | Apple Developer Documentation
You customize your embedded web content by implementing WebView delegates to handle certain aspects of the process. WebView objects have multiple delegates ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It appears to be getting the notification about the second webview and treating it as a redirect, so choosing the new one (which is how the system handles new windows being opened. I’ll look into what can be done about this.
I can confirm that on appium@beta with the latest
appium-remote-debugger
version my test works correctly.Thanks a lot for your assistance with this issue.