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 switch to web view in hybrid app.

See original GitHub issue

The problem

Hi, I am trying to switch to web context from native and then switch back. However it throws an error at me which I have tried to solve with solutions found online but nothing seems to be working. The code flow is to click an element within the native context which then redirects to a webpage to approve authentication and then return back to the native context.

The error is thrown by:

driver.context((String) contextNames.toArray()[1]);

which is:

[Chromedriver] Error: Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. (Original error: unknown error: Failed to get sockets matching: @webview_devtools_remote_.*23686

My code chunk is:

` wait.until(ExpectedConditions.visibilityOfElementLocated (By.id(“com.android.chrome:id/location_bar”)));

    Set<String> contextNames = driver.getContextHandles();
    for (String contextName : contextNames) {
        System.out.println(contextNames); 
    }

    driver.context((String) contextNames.toArray()[1]); 
    System.out.println("Expected chrome: "+driver.getContext());

    WebView.setWebContentsDebuggingEnabled(true);

    driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/div/div[4]/a[1]")).click();

    driver.context("NATIVE_APP");

`

as well as in my capabilities I have the following:

` capabilities.setCapability(“appium-version”, “1.7.2”);

    capabilities.setCapability("platformName", "Android");

    capabilities.setCapability("deviceName", deviceName);

    capabilities.setCapability("appPackage", "de.codenauts.hockeyapp");

    capabilities.setCapability("appActivity","net.hockeyapp.client.HomeActivity");

    capabilities.setCapability("setWebContentsDebuggingEnabled","true");

`

Environment

My Appium version is 1.7.2 The mobile device is running chrome 65.0.3325.109 The chromedriver version I have is 3.38 node version v8.10.0 Android 6.01, real device: LG-k557

Link to Appium logs

The Logs can be found here: https://gist.github.com/mmaxin/6cdf8cc14c372ed763b9e41599f88494

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
prat3ikcommented, Feb 2, 2019

I am also facing the same:

  • Appium 1.10.0
  • Driver info: chromedriver=2.46.628411 (Mac OS)
  • React Native
1reaction
prevostccommented, Oct 11, 2018

Same issue here:

  • Appium 1.9.1
  • Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-134-generic x86_64
  • cordova 7.0.1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to switch to web view in a hybrid app on iOS 13 #13285
The problem Switching to web view in a hybrid app test hangs only on iOS 13 but works fine on iOS 12 and...
Read more >
Hybrid App Does not show WebView Context and Not able to ...
When I run the Sample Code of Locating Element. It's not working now. The same code was working previously. I have tried switching...
Read more >
Hybrid Android App testing. Can't switch to WEBVIEW - Support
Hello, I am trying to do automated testing. I am using linux RH. My code: import io.appium.java_client.android.
Read more >
Appium: Switch to Native & Web-view context for Hybrid App
In this video, we are going to see how we can switch from Native context to Webview context to automate hybrid app in...
Read more >
Automating hybrid apps - appium - Read the Docs
Entering the web view context · Navigate to a portion of your app where a web view is active · Retrieve the currently...
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