question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS: Wrong Context Selected When App Has Multiple WebViews

See original GitHub issue

The 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:

https://github.com/Dan-Maor/multiwebview

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
imurchiecommented, Jan 7, 2020

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.

0reactions
Dan-Maorcommented, Jan 9, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found