# Appium only show native app context, is does not recognises the webview context for android app

**URL:** <https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348>\
**Category:** Issues/Bugs\
**Created:** [September 13, 2014, 1:14pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348 "2014-09-13T13:14:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quality\_Analyst](https://discuss.appium.io/letter_avatar_proxy/v4/letter/q/977dab/32.png) [@Quality\_Analyst](https://discuss.appium.io/u/Quality_Analyst)\
**Post date:** [September 13, 2014, 1:14pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/1 "2014-09-13T13:14:17Z")

</div>

Set contextNames = driver.getContextHandles();  
for (String contextName : contextNames) {  
System.out.println(“Starting app”+contextNames);  
} /// above code only returns NATIVE APP, even though for login verification the app switched to webview context, but appium does not recognises.

below is the details:

File appDir = new File(“C://sdk//build-tools//android-4.3”);  
File app = new File(appDir, “Test.apk”);  
//Set up desired capabilities and pass the Android app-activity and app-package to Appium  
DesiredCapabilities capabilities = new DesiredCapabilities();  
capabilities.setCapability(“app”, app.getAbsolutePath());  
capabilities.setCapability(CapabilityType.ACCEPT\_SSL\_CERTS, true);  
capabilities.setCapability(CapabilityType.BROWSER\_NAME, “Android”);  
// capabilities.setCapability(CapabilityType.VERSION, “4.3”);  
capabilities.setCapability(CapabilityType.PLATFORM, “Windows”);  
capabilities.setCapability(CapabilityType.SUPPORTS\_NETWORK\_CONNECTION,true);  
capabilities.setCapability(CapabilityType.SUPPORTS\_WEB\_STORAGE,true);  
capabilities.setCapability(CapabilityType.SUPPORTS\_SQL\_DATABASE,true);  
capabilities.setCapability(“app-package”, “com.home.simple”); // This is package name of your app (you can get it from apk info app)  
capabilities.setCapability(“app-wait-activity”, “com.dynamicapp.Activity”);  
capabilities.setCapability(“app-activity”, “com.dynamicapp.Activity”);  
capabilities.setCapability(“device”,“Android”);  
capabilities.setCapability(“platformName”, “Android”);  
capabilities.setCapability(“deviceType”,“phone”);  
capabilities.setCapability(“autoWebview”, true);  
capabilities.setCapability(“deviceName”, “AVD”);  
capabilities.setCapability(“newCommandTimeout”,24000);  
capabilities.setCapability(“autoWebviewTimeout”,6000);

```
        // This is Launcher activity of your app (you can get it from apk info app)
          
	 try {
		 driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
		    
		 
		    } catch(Exception e) {
		   	 e.printStackTrace();
		    }
```

---

<div class="post-metadata">

**Author:** ![Antony\_Barnabas](https://discuss.appium.io/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@Antony\_Barnabas](https://discuss.appium.io/u/Antony_Barnabas)\
**Post date:** [September 13, 2014, 7:26pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/2 "2014-09-13T19:26:09Z")

</div>

Does your app is set with setWebContentsDebuggingEnabled to true

---

<div class="post-metadata">

**Author:** ![NDL](https://discuss.appium.io/letter_avatar_proxy/v4/letter/n/b2d939/32.png) [@NDL](https://discuss.appium.io/u/NDL)\
**Post date:** [September 14, 2014, 5:32am UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/3 "2014-09-14T05:32:27Z")

</div>

I have the same issue when i run from the emulator. When I run it with the device. appium successfully identifies the webview. Please let me know if you come across a solution. Thank you.

---

<div class="post-metadata">

**Author:** ![Mayuresh\_Shirodkar](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@Mayuresh\_Shirodkar](https://discuss.appium.io/u/Mayuresh_Shirodkar)\
**Post date:** [September 30, 2014, 7:22am UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/4 "2014-09-30T07:22:11Z")

</div>

Even i have the same issue,For me Appium gives Native as well as Webview on Emulator,But on Real device it gives just Native view.(Android device 4.4.2)

---

<div class="post-metadata">

**Author:** ![Hassan\_Radi](https://discuss.appium.io/user_avatar/discuss.appium.io/hassan_radi/32/4077_2.png) [@Hassan\_Radi](https://discuss.appium.io/u/Hassan_Radi)\
**Post date:** [September 30, 2014, 7:29am UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/5 "2014-09-30T07:29:30Z")

</div>

The issue happens with me, but not persistently. It happens from time to time, but I can see webviews using Appium newest release.

Not sure what is causing that inconsistent behavior though ???

---

<div class="post-metadata">

**Author:** ![Tim](https://discuss.appium.io/letter_avatar_proxy/v4/letter/t/ce73a5/32.png) [@Tim](https://discuss.appium.io/u/Tim)\
**Post date:** [October 6, 2014, 2:39pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/6 "2014-10-06T14:39:10Z")

</div>

I have the same issue as Mayuresh\_Shirodkar, I can see the WEBVIEW on an ANDROID emulator but when I try to run the same test against a real device with the same software level and app, only the NATIVE context is found. (Android 4.4.2)

---

<div class="post-metadata">

**Author:** ![jonahss](https://discuss.appium.io/user_avatar/discuss.appium.io/jonahss/32/5340_2.png) [@jonahss](https://discuss.appium.io/u/jonahss)\
**Post date:** [October 6, 2014, 7:19pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/7 "2014-10-06T19:19:57Z")

</div>

Hmm. Do you try to access the WEBVIEW context right away? Try adding a couple-second delay before requesting the webview.

---

<div class="post-metadata">

**Author:** ![Tim](https://discuss.appium.io/letter_avatar_proxy/v4/letter/t/ce73a5/32.png) [@Tim](https://discuss.appium.io/u/Tim)\
**Post date:** [October 6, 2014, 7:51pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/8 "2014-10-06T19:51:04Z")

</div>

Hi jonahss, Thanks for the suggestion. Yes, I have tried adding a ten second delay between opening the app and trying to access the webview but unfortunately that didn’t help. As I said, this works without any issues on an emulator running the same version of the app and the same API and software level as the real device.

I also tried upgrading to the latest version of appium (1.3 beta), I might try going to an older version and see if that helps.

---

<div class="post-metadata">

**Author:** ![Steve\_Thompson](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Steve\_Thompson](https://discuss.appium.io/u/Steve_Thompson)\
**Post date:** [October 6, 2014, 10:08pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/9 "2014-10-06T22:08:48Z")

</div>

I’m running into a similar issue, except I never change context because I’ve never had it work (chromedriver never connects and there’s nothing useful in the debug log). I’m stumped as to why I can still navigate and manipulate webview elements without ever changing context on nexus 5 running 4.4.2. The nexus is unlocked (I saw some info on forums claiming this “should” fix chromedriver issues, but it didn’t help me. Is this an actual requirement?)  
See:

> [@Appium android webviews documentation/xpath issues](https://discuss.appium.io/t/appium-android-webviews-documentation-xpath-issues/661/2):
>
> We need better webview automation examples, in my case python specifically. Somehow I’ve partially automated webview testing without switching to webview context (except for the fact that UI navigation sporadically breaks for a while and then suddenly start working again). My app has lots of fragments and activities that use webviews. Is there a global webview context, or would each webview be different and require restarting chromedriver several times? On top of that I’ve never yet had chro…

---

<div class="post-metadata">

**Author:** ![jonahss](https://discuss.appium.io/user_avatar/discuss.appium.io/jonahss/32/5340_2.png) [@jonahss](https://discuss.appium.io/u/jonahss)\
**Post date:** [October 7, 2014, 5:23pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/10 "2014-10-07T17:23:51Z")

</div>

I strongly suggest against going to an older version! You’ll end up needing to update for newer features anyways.

---

<div class="post-metadata">

**Author:** ![Mayuresh\_Shirodkar](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@Mayuresh\_Shirodkar](https://discuss.appium.io/u/Mayuresh_Shirodkar)\
**Post date:** [October 10, 2014, 9:19am UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/11 "2014-10-10T09:19:19Z")

</div>

> [@Tim](#):
>
> I have tried adding a ten second delay between opening the app and trying to access the webview but unfortunately that didn’t help.

Hey Johnass,Even I have tried adding a ten second delay between opening the app and trying to access the webview,Din’t work for me too.  
Anything else that can be tried?

---

<div class="post-metadata">

**Author:** ![Hassan\_Radi](https://discuss.appium.io/user_avatar/discuss.appium.io/hassan_radi/32/4077_2.png) [@Hassan\_Radi](https://discuss.appium.io/u/Hassan_Radi)\
**Post date:** [October 10, 2014, 11:37am UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/12 "2014-10-10T11:37:22Z")

</div>

@Mayuresh_Shirodkar @Steve_Thompson @Tim @NDL @Antony_Barnabas @Quality_Analyst

I ran across the same issue on a real device and after trying to run Appium from the last master build, the webview was visible and it worked. Please do give it a try to run from master and let me know if it works for you too.

And please make sure that your webview is visible by assuring that:

> [@Antony\_Barnabas](#):
>
> Does your app is set with setWebContentsDebuggingEnabled to true

And also try to inspect that it’s visible by seeing if [Chrome remote debugger](https://developer.chrome.com/devtools/docs/remote-debugging) sees it.

---

<div class="post-metadata">

**Author:** ![Steve\_Thompson](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Steve\_Thompson](https://discuss.appium.io/u/Steve_Thompson)\
**Post date:** [October 21, 2014, 12:35am UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/13 "2014-10-21T00:35:28Z")

</div>

I just tried appium 1.2.4 on a nexus 5 running both 4.4.2 and 4.4.4. The app does have the webview visible (verified by chrome remote debugger). Still no luck.

---

<div class="post-metadata">

**Author:** ![ramshankar\_testing](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/f9ae1b/32.png) [@ramshankar\_testing](https://discuss.appium.io/u/ramshankar_testing)\
**Post date:** [October 21, 2014, 11:55am UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/14 "2014-10-21T11:55:10Z")

</div>

Even I am also facing same issue on 4.4.2 android device.

Has anyone got solution for this ?

---

<div class="post-metadata">

**Author:** ![ramshankar\_testing](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/f9ae1b/32.png) [@ramshankar\_testing](https://discuss.appium.io/u/ramshankar_testing)\
**Post date:** [October 21, 2014, 12:08pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/15 "2014-10-21T12:08:08Z")

</div>

@Hassan_Radi ,

Can you please tell me the procedure to run appium from master build ?

I tried with command line and went to bin folder and given command node appium. But could not able to open.

---

<div class="post-metadata">

**Author:** ![Hassan\_Radi](https://discuss.appium.io/user_avatar/discuss.appium.io/hassan_radi/32/4077_2.png) [@Hassan\_Radi](https://discuss.appium.io/u/Hassan_Radi)\
**Post date:** [October 21, 2014, 1:05pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/16 "2014-10-21T13:05:57Z")

</div>

This should help you run Appium from source:

> <https://github.com/appium/appium/blob/master/docs/en/contributing-to-appium/appium-from-source.md>

---

<div class="post-metadata">

**Author:** ![ramshankar\_testing](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/f9ae1b/32.png) [@ramshankar\_testing](https://discuss.appium.io/u/ramshankar_testing)\
**Post date:** [October 23, 2014, 10:03am UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/18 "2014-10-23T10:03:22Z")

</div>

![](https://discuss.appium.io/uploads/default/301/9dd3742d871545ee.PNG)

@Hassan_Radi,  
Please have a look this error. I am trying on windows machine. all path and all I set but still I am getting this issue.

---

<div class="post-metadata">

**Author:** ![Hassan\_Radi](https://discuss.appium.io/user_avatar/discuss.appium.io/hassan_radi/32/4077_2.png) [@Hassan\_Radi](https://discuss.appium.io/u/Hassan_Radi)\
**Post date:** [October 23, 2014, 10:10am UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/19 "2014-10-23T10:10:40Z")

</div>

[This](http://stackoverflow.com/questions/25093276/nodejs-windows-error-enoent-stat-c-users-rt-appdata-roaming-npm) will help solve your problem.

---

<div class="post-metadata">

**Author:** ![ramshankar\_testing](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/f9ae1b/32.png) [@ramshankar\_testing](https://discuss.appium.io/u/ramshankar_testing)\
**Post date:** [October 24, 2014, 8:08am UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/22 "2014-10-24T08:08:35Z")

</div>

@Hassan_Radi,  
I could able to start latest appium from source but still I am not able to see web view from here as well. Any idea ?

It is android 4.4.2

---

<div class="post-metadata">

**Author:** ![Nitinvermaa1](https://discuss.appium.io/letter_avatar_proxy/v4/letter/n/4af34b/32.png) [@Nitinvermaa1](https://discuss.appium.io/u/Nitinvermaa1)\
**Post date:** [November 30, 2014, 7:56pm UTC](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348/24 "2014-11-30T19:56:44Z")

</div>

Hi, i am trying to automate Google search from device nexus 7 with 4.4.4. Below are the prerequisite.

Real device: Nexus 7 with 4.4.4  
Browser: Chrome  
Appium: 1.2.4.1 version  
Java 1.7  
Java-client 1.6.0  
OS: Windows 8.1

I have written a code which open chrome, but when i am trying to switch to webview, it leads to no success. It only showing me context as “NATIVE\_APP”. Whatever suggestion given in this post i have already tried, but no success. Please help me out to resolve this. Below is my code.

Code:

WebDriver driver;

```
	DesiredCapabilities capabilities = new DesiredCapabilities();
	   
	   capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
	   capabilities.setCapability(CapabilityType.VERSION, "4.4.2");
	   capabilities.setCapability("platformName", "Android");
	   capabilities.setCapability("automationName", "Appium");
	   //capabilities.setCapability("appium-version", "1.2.4.1");
	   
	   capabilities.setCapability("deviceName", "015d2994cc4c0618");
     capabilities.setCapability("appPackage", "com.android.chrome"); // This is package name of your app (you can get it from apk info app)
     capabilities.setCapability("appActivity", "com.android.chrome.Main"); // This is Launcher activity of your app (you can get it from apk info app)
     
      
     driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
     
     //here is WebElement instantiation
     PageFactory.initElements(new AppiumFieldDecorator(driver), capabilities);
      
    
    System.out.println(((AppiumDriver) driver).getOrientation()); 
     //((AppiumDriver) driver).openNotifications();
    
    
     
    System.out.println("done");
    Thread.sleep(50000L);
    
      Set<String> contextNames = ((AppiumDriver) driver).getContextHandles();
        for (String contextName : contextNames) {
            System.out.println(contextName);
            ((AppiumDriver) driver).context(contextName);
           // System.out.println("it worked "+ driver.getTitle());
           
            if (contextName.contains("WEBVIEW")){
                 ((AppiumDriver) driver).context(contextName);
                 Thread.sleep(10000);
                 driver.findElement(By.id("sfdiv")).sendKeys("Appium");
                 String Text1 = driver.findElement(By.cssSelector(".module_operation_title")).getText();
      	       System.out.println(Text1);
      	       Thread.sleep(10000);
      	        driver.findElement(By.cssSelector(".form_details")).click();
      	       Thread.sleep(5000);
      	      
            }

```

* * *

[Next page](https://discuss.appium.io/t/appium-only-show-native-app-context-is-does-not-recognises-the-webview-context-for-android-app/348.md?page=2)
