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.

Unable to find WEBVIEW context with iOS 13

See original GitHub issue

The problem

I am unable to find WEBVIEW context using driver.contexts. It only shows [‘NATIVE_APP’] using get_all_context. I have no problem getting and switching to WEBVIEW using Appium 1.13 with iOS 12.0. However, recently I want to upgrade to iOS 13 using the latest Appium. I keep running into this problem.

Environment

  • Appium version: 1.17.1-beta.0
  • Last Appium version that did not exhibit the issue: 1.13 + iOS 12.0
  • Desktop OS/version used to run Appium: MacOS 10.15.4 / Xcode 11.4
  • Node.js version: 13.12.0
  • Npm or Yarn package manager: 6.14.4
  • Mobile platform/version: iOS 13.0
  • Real device or emulator/simulator: iOS Simulator
  • Appium CLI or Appium.app|exe: Appium CLI
/usr/local/lib
└─┬ appium@1.17.1-beta.0
  ├─┬ appium-ios-driver@4.6.2
  │ └── appium-remote-debugger@4.5.0 
  └─┬ appium-xcuitest-driver@3.21.1
    └── appium-remote-debugger@8.9.0 

Details

There is no issue with Appium 1.13 + iOS 12.0 switching webview in my app. I don’t know what I did wrong in this setup. I have already update everything to the latest version as I can. It seems like appium can not find any WEBVIEW at all, since I keeps getting only [NATIVE_APP]. I have tried:

  1. Uninstall and reinstall appium CLI both 1.17.1 and beta
  2. Add Capabilities like: ‘fullContextList’: True I am still unable to resolve this issue.

Link to Appium logs

GIST Link : https://gist.github.com/jerislee/54e9cf4fc7c944673b779b10b6de64dc Part of important log : https://gist.github.com/jerislee/82c6722b6e9157dbabcf0e43e6378107

Code To Reproduce Issue [ Good To Have ]

    def switch_context(self, context):  # context = 'WEBVIEW' / 'NATIVE_APP'
        time.sleep(10)
        self.logger.info("[Automation Log]: before switch " + self.driver.current_context)

        while context not in self.driver.current_context:
            if context == "WEBVIEW":
                self.logger.info(self.driver.contexts)
                try:
                    self.driver.switch_to.context(self.driver.contexts[1])
                except BaseException as msg:
                    self.logger.info(msg)
            elif context == "NATIVE_APP":
                self.driver.switch_to.context(context)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:37 (18 by maintainers)

github_iconTop GitHub Comments

14reactions
jimarasimcommented, Jul 6, 2020

Still having issues with this. Here is a repro using Appium Desktop - Get All Contexts

ios 13.4 appium 1.17.1-1

Capabilities: { “app”: “app”, “platformName”: “iOS”, “platformVersion”: “13.4”, “deviceName”: “iPhone 11 Pro Max 13.4”, “automationName”: “XCUITest”, “webviewConnectTimeout”: “90000”, “safariLogAllCommunication”: true }

2reactions
SHI-ZPcommented, Nov 4, 2020

for(int i = 0; i<30; i++) { Thread.sleep(1000); Set<String> contextNames = driver.getContextHandles(); for (String contextName : contextNames) { System.out.println(contextName); //prints out something like NATIVE_APP \n WEBVIEW_1driver.quit(); } }

works for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Context cannot find webviews on 1.3.1 on iOS - Appium Discuss
I am unable to find webviews using context. Set<String> contextNames =webDriver.getContextHandles(); System.out.println(contextNames.size()) ...
Read more >
Cannot find WebViewContext for WkWebView on iOS ...
I have an ios app that first starts the webview directly. When I then try to switch the context, Appium doesn't find the...
Read more >
I'm only able to see NATIVE_APP context, how do I get ...
I'm only able to see NATIVE_APP context, how do I get WEBVIEW context? ... iOS test, it could be helpful to use WEBVIEW...
Read more >
Unable to get available contexts in Hybrid iOS app - Archive
baottran March 13, 2019, 6:34am #1. Hi everyone,. Given that I'm standing at a screen have WebView and Native context in iOS native...
Read more >
appium/appium - Gitter
... of iOS version to be released (a new beta) or a new appium version. On my end it's okish, 30% of tests...
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