# Cannot find WebView when searching for context in Hybrid application

**URL:** <https://discuss.appium.io/t/cannot-find-webview-when-searching-for-context-in-hybrid-application/5644>\
**Category:** Issues/Bugs\
**Created:** [August 18, 2015, 8:11am UTC](https://discuss.appium.io/t/cannot-find-webview-when-searching-for-context-in-hybrid-application/5644 "2015-08-18T08:11:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rjimms](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@Rjimms](https://discuss.appium.io/u/Rjimms)\
**Post date:** [August 18, 2015, 8:11am UTC](https://discuss.appium.io/t/cannot-find-webview-when-searching-for-context-in-hybrid-application/5644/1 "2015-08-18T08:11:04Z")

</div>

Hello,

I’m currently using Appium and have hit an issue with regard to finding the WebView context. Using UIAutomator I can inspect the WebView and see its child elements, however I cannot access any of these by using CSS selector/ XPATH because I cannot switch to WebView.

I have tried looping over driver.getContextHandles(), however this simply returns “NAVTIVE\_APP”.

Android version being used is 5.0.1 and the latest version of Appium.

Can anyone shed any light as to why this may be happening?

---

<div class="post-metadata">

**Author:** ![amitjaincoer191](https://discuss.appium.io/user_avatar/discuss.appium.io/amitjaincoer191/32/5339_2.png) [@amitjaincoer191](https://discuss.appium.io/u/amitjaincoer191)\
**Post date:** [August 18, 2015, 8:48am UTC](https://discuss.appium.io/t/cannot-find-webview-when-searching-for-context-in-hybrid-application/5644/2 "2015-08-18T08:48:35Z")

</div>

For using webview context enable WebView debugging, for this “setWebContentsDebuggingEnabled” flag should be inside the WebView class by developer.  
Then using chrome remote debugger you can spy or inspect webview elements  
url : [https://developer.chrome.com/devtools/docs/remote-debugging9](https://developer.chrome.com/devtools/docs/remote-debugging9)

---

<div class="post-metadata">

**Author:** ![Rjimms](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@Rjimms](https://discuss.appium.io/u/Rjimms)\
**Post date:** [August 18, 2015, 8:58am UTC](https://discuss.appium.io/t/cannot-find-webview-when-searching-for-context-in-hybrid-application/5644/3 "2015-08-18T08:58:27Z")

</div>

Is this the case for being able to identify the “WEBVIEW” in get contexts too as I am not able to view this at all?

The code I use is :

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

However all that is printed out [NATIVE\_APP]

---

<div class="post-metadata">

**Author:** ![amitjaincoer191](https://discuss.appium.io/user_avatar/discuss.appium.io/amitjaincoer191/32/5339_2.png) [@amitjaincoer191](https://discuss.appium.io/u/amitjaincoer191)\
**Post date:** [August 18, 2015, 9:42am UTC](https://discuss.appium.io/t/cannot-find-webview-when-searching-for-context-in-hybrid-application/5644/4 "2015-08-18T09:42:02Z")

</div>

You should ask app developer to set this flag “setWebContentsDebuggingEnabled” or enable webview debugging while creating app then only getContextHandles() will detect both the contexts  
Also app should be build for Android 4.4+ version

---

<div class="post-metadata">

**Author:** ![Rjimms](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@Rjimms](https://discuss.appium.io/u/Rjimms)\
**Post date:** [August 18, 2015, 9:57am UTC](https://discuss.appium.io/t/cannot-find-webview-when-searching-for-context-in-hybrid-application/5644/5 "2015-08-18T09:57:15Z")

</div>

Thank’s for the quick reply. I’ll do this now and will hopefully have this resolved soon.

---

<div class="post-metadata">

**Author:** ![kirill](https://discuss.appium.io/user_avatar/discuss.appium.io/kirill/32/1205_2.png) [@kirill](https://discuss.appium.io/u/kirill)\
**Post date:** [August 19, 2015, 5:36am UTC](https://discuss.appium.io/t/cannot-find-webview-when-searching-for-context-in-hybrid-application/5644/6 "2015-08-19T05:36:34Z")

</div>

UIAutomator inspector shouldn’t show you any WebView children elements if that’s true web/hybrid app. Go to Chrome devices remote debugging (chrome://inspect/#devices) and check if there is any WebView. If no, that means you have native app.

---

<div class="post-metadata">

**Author:** ![arvinds97](https://discuss.appium.io/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@arvinds97](https://discuss.appium.io/u/arvinds97)\
**Post date:** [September 3, 2020, 2:05pm UTC](https://discuss.appium.io/t/cannot-find-webview-when-searching-for-context-in-hybrid-application/5644/7 "2020-09-03T14:05:46Z")

</div>

Hi ,  
I have been experiencing the same issue, with a twist tho. The “setWebContentsDebuggingEnabled” is set to true. However, everytime I run , I’m getting different number of contexts. Yesterday I was getting only the "NATIVE\_APP’ one, today morning I got “NATIVE\_APP” and “WEBVIEW\_chrome” and now I’m getting those two and another one “WEBVIEW\_\<package\_name\>”. Why is this happening?  
I have no clue
