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.

What are the necessary changes to be done for iOS source code to see the "Webview" enabled in Hybrid App.

See original GitHub issue

The problem

Detecting the WEBVIEW context in iOS hybrid app. IOSDRIVER class provides only NATIVE context and not WEBVIEW context

Environment

  • Appium version (or git revision) that exhibits the issue: 1.6.4
  • Desktop OS/version used to run Appium: MAC Captian 10.11.6
  • Mobile platform/version under test: iPhone 9.2.3
  • Real device or emulator/simulator: Real device
  • Appium CLI or Appium.app|exe: 1.0.0

Details

When i try to print the getcontext from IOSDriver class, the Webview context is not been returned by this class. Only “NATIVEVIEW” is printed. If same is followed in Android build i see WebVIEW and NATIVE been returned by respective driver class.

Do i need to make any changes to iOS source code before i generate an IPA file? Please help.

The code i am using to get or switch context is:

// Switching to iOS webview
IOSDriver<MobileElement> iosDriver = (IOSDriver<MobileElement>) appiumDriver;
Set<String> contextNames = iosDriver.getContextHandles();
for (String contextName : contextNames) {
    System.out.println(contextName); //prints out something like [NATIVE_APP, WEBVIEW_<APP_PKG_NAME>]
    if(contextName.contains("WEBVIEW")){
        iosDriver.context(contextName);
        System.out.println("Switched to: "+contextName);
        break;
    }
}
return iosDriver;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
chethanshetty09commented, Sep 7, 2017

I added one Capability and then it worked. capabilities.setCapability(“instrumentApp”, “true”); 👍

Thanks.

0reactions
lock[bot]commented, Apr 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automating Hybrid Apps - Appium
Automating hybrid apps; Entering the web view context ... One of the core principles of Appium is that you shouldn't have to change...
Read more >
WKWebView | Apple Developer Documentation
A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app's UI. A web view supports...
Read more >
JavaScript Manipulation on iOS Using WebKit | Capital One
The new framework dramatically improved both the performance and flexibility of adding web content into iOS apps, giving developers more control and more...
Read more >
iOS WebViews - HackTricks
WebViews are in-app browser components for displaying interactive web content. They can be used to embed web content directly into an app's user...
Read more >
Mobile Apps: Native, Hybrid, and WebViews - UXmatters
Quora is a WebView app of some sort, with a few clearly native components along the edges. As you can see in Figure...
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