# Elements in webview are not found in webview context (ios)

**URL:** <https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322>\
**Category:** Support\
**Created:** [September 11, 2014, 9:49pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322 "2014-09-11T21:49:46Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeffrey\_Blaze](https://discuss.appium.io/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@Jeffrey\_Blaze](https://discuss.appium.io/u/Jeffrey_Blaze)\
**Post date:** [September 11, 2014, 9:49pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/1 "2014-09-11T21:49:46Z")

</div>

I’ve got a webview in this hierarchy:

//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView

It contains 2 UIATextField’s and one UIATextField[1]

When I look for the elements while still in the native context, they are all found. In addition, I can click the button object while in the native context (strange)…

But when I switch to the WEBVIEW\_1 context, none of the elements can be seen. Any ideas why?

BTW, while in native context I can see the Email element using this locator:  
“//UIAScrollView/UIAWebView/UIATextField[@value=‘Email’]”

But while in WEBVIEW\_1 context the element cannot be found using that locator, nor these:  
“//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]”  
“//UIAWebView/UIATextField[1]”  
“//UIATextField[1]”

QUESTION: While in a webview context, do we need to use a locator strategy other than the above?

---

<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 29, 2014, 9:49pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/2 "2014-09-29T21:49:19Z")

</div>

Yes. You need to access the element as shown below

findElement(By.xpath("//input[@name=‘firstName’]")).

You have to use the page source to find the name of the element. Calling driver.getPageSource() will give the source code. Hope this help.

---

<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 2, 2014, 1:13pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/4 "2014-10-02T13:13:30Z")

</div>

@Jeffrey_Blaze  
You can use Chrome built-in feature (Remote debugging) to inspect for elements in webviews instead of getting the html source.

Use this [link](https://developer.chrome.com/devtools/docs/remote-debugging).

---

<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 2, 2014, 9:09pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/5 "2014-10-02T21:09:00Z")

</div>

If we can access and manipulate UI elements without switching context, what’s the point of switching context?

---

<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 3, 2014, 8:57am UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/6 "2014-10-03T08:57:47Z")

</div>

> [@Steve\_Thompson](#):
>
> If we can access and manipulate UI elements without switching context, what’s the point of switching context?

You can’t access nor manipulate UI elements without switching contexts, I was just giving **Jeffrey** a simpler solution to inspect for elements instead of getting the whole HTML source.

---

<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:** [October 3, 2014, 1:30pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/7 "2014-10-03T13:30:57Z")

</div>

Steve, It never worked for me without switching context so I am wondering how you could able to do that

---

<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:11pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/8 "2014-10-06T22:11:45Z")

</div>

Yeah, I’m quite stumped and have yet to hear back on my post.

> [@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:** ![Patrick\_Shay](https://discuss.appium.io/letter_avatar_proxy/v4/letter/p/35a633/32.png) [@Patrick\_Shay](https://discuss.appium.io/u/Patrick_Shay)\
**Post date:** [March 12, 2015, 11:25pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/9 "2015-03-12T23:25:17Z")

</div>

I was wondering if anyone made progress on this. I’m using the IOSDriver, and after switching to the webview, I can find elements that exist by using linkText.

I can’t find UIAButtons by using findElementsByName(). However, if I use an appium inspector, I am able to locate the UIAButtons by switching the context to webview, and then searching by the UIAButton’s name.

(I can switch context and locate a UIAButton by name using Appium Inspector, but not while running a test. It does work for finding elements by link text though.)

---

<div class="post-metadata">

**Author:** ![Mobile\_Test\_Test](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/a9a28c/32.png) [@Mobile\_Test\_Test](https://discuss.appium.io/u/Mobile_Test_Test)\
**Post date:** [May 13, 2015, 11:16am UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/10 "2015-05-13T11:16:02Z")

</div>

@Hassan_Radi i checked the link and i found that its given only for ANdroid…  
How to inspect WEBVIEW elements for IOS hybrid app.

I tried switching context to WEBVIEW and dumped the pageSource and started picking elements from the source file. But for some objects i was not able to figure out the elements manually.

Is there any way to inspect elements in iOS hyrbid App;s webview  
Thanks

---

<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:** [May 13, 2015, 11:20am UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/11 "2015-05-13T11:20:06Z")

</div>

@Mobile_Test_Test  
Check [this](http://stackoverflow.com/a/12607124/1872682) out 😄

---

<div class="post-metadata">

**Author:** ![MeenakshiMehta](https://discuss.appium.io/user_avatar/discuss.appium.io/meenakshimehta/32/5203_2.png) [@MeenakshiMehta](https://discuss.appium.io/u/MeenakshiMehta)\
**Post date:** [July 14, 2015, 11:34pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/12 "2015-07-14T23:34:01Z")

</div>

Did you find a solution to this issue?

---

<div class="post-metadata">

**Author:** ![Phanindra007](https://discuss.appium.io/user_avatar/discuss.appium.io/phanindra007/32/2141_2.png) [@Phanindra007](https://discuss.appium.io/u/Phanindra007)\
**Post date:** [April 14, 2016, 7:45pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/13 "2016-04-14T19:45:36Z")

</div>

Any Solution for this? I am stuck here no clue what i can do

---

<div class="post-metadata">

**Author:** ![Mani\_Maran\_Chandraba](https://discuss.appium.io/user_avatar/discuss.appium.io/mani_maran_chandraba/32/4702_2.png) [@Mani\_Maran\_Chandraba](https://discuss.appium.io/u/Mani_Maran_Chandraba)\
**Post date:** [April 15, 2016, 1:11pm UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/14 "2016-04-15T13:11:03Z")

</div>

> [@IOS-Customized UIImage is not visible through Appium inspector](https://discuss.appium.io/t/ios-customized-uiimage-is-not-visible-through-appium-inspector/7815/2):
>
> may be you can validate the UIAButton’s value attribute for image’s path. Just a suggestion.

Please refer it…!

---

<div class="post-metadata">

**Author:** ![Phanindra007](https://discuss.appium.io/user_avatar/discuss.appium.io/phanindra007/32/2141_2.png) [@Phanindra007](https://discuss.appium.io/u/Phanindra007)\
**Post date:** [May 5, 2016, 11:24am UTC](https://discuss.appium.io/t/elements-in-webview-are-not-found-in-webview-context-ios/322/15 "2016-05-05T11:24:53Z")

</div>

Thanks for reply. as you said the issue is developers has not enabled the visibility of the elements.
