# Not able to identify element in WEBVIEW in iOS hyprid app(build in Ionic) automation using Appium on real device

**URL:** <https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244>\
**Category:** Issues/Bugs\
**Created:** [May 17, 2016, 1:13pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244 "2016-05-17T13:13:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suraj786](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@Suraj786](https://discuss.appium.io/u/Suraj786)\
**Post date:** [May 17, 2016, 1:13pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/1 "2016-05-17T13:13:09Z")

</div>

I was trying to automate the hybrid app build using ionic2/Angular2 and typescript.  
I am using C# for code writing. test are in BDD - specflow Versions: iOS:9.3.1 Xcode: 7.3 Appium: 1.4.13

I am not able to identify elements after swtiching Context to WEBVIEW.

Calling IOSDriver using below code

> private IOSDriver driver = null;

> public IOSDriver GetDriver(string platformVersion, string deviceName, string udid ,string appPath, string serverUri)  
> {  
> Capabilities iosCapabilities = new Capabilities();  
> DesiredCapabilities capabilities = iosCapabilities.Get(platformVersion, deviceName, udid, appPath);  
> driver = new IOSDriver(new Uri(serverUri), capabilities, TimeSpan.FromSeconds(Constants.DriverWaitTime));  
> driver.Manage ().Timeouts ().ImplicitlyWait (TimeSpan.FromSeconds(Constants.ImplicitWaitTime));

> ```
> var contextNames = driver.Contexts;
> driver.Context = contextNames[1];
> 
> ```

> ```
> driver.FindElement(By.Xpath(locator)).Click();
> 
> ```

> }

Setting Capabilities as

> private DesiredCapabilities capabilities = new DesiredCapabilities();

> capabilities.SetCapability (“appium-version”, Constants.AppiumVersion);  
> capabilities.SetCapability (“platformName”, Constants.PlatformName);  
> capabilities.SetCapability(“autoWebView”, “true”);  
> capabilities.SetCapability(“browserName”, “iOS”);  
> capabilities.SetCapability (“platformVersion”, Constants.PlatformVersion);  
> capabilities.SetCapability(“deviceName”, deviceName);  
> capabilities.SetCapability(“app”, appPath);  
> capabilities.SetCapability(“udid”, udid);

Am I setting the capabilities in correct way?

Solution tried:

1. I checked using browserName capbility as blank/safari but didn’t worked
2. Also, I installed ios-webkit-debug-proxy and started proxy using terminal in background on my mac

_Problem is I am not able to identify elements in WEBVIEW even after switching the context._

`My Observation:->`

After launching the app, in appium inspector I am able to see all the elements and I am trying to click on textbox to enter some value

Xpath of textbox(as i can view in appium inspector window):  
**“//UIAApplication[1]/UIAWindow[1]/UIAScrollView[2]/UIAWebView[1]/UIATextField[1]”**

> var contextNames = driver.Contexts

is giving me list to views(In my case 2 views: NATIVE\_APP, WEBVIEW\_1) WebView context is dynamically updating from 1,2,3 and so on…

As soon as I call

> diver.Context=contextNames[1]; //setting context to WEBVIEW

and refresh the appium inspector I am not able to see/identify single element.Everything goes away.

Why I am not able to see/identify elements after switching to webview. (Note: As soon as I Switch back to driver.Context=“NATIVE\_APP” every element becomes visible in appium inspector but still I am not able to click)

Error is thrown as: **_“An element could not be located using given search parameter”_**

Manually also when I try to tap or sendkeys using appium inspector it is not letting me do so(after lauching tha app manually using inspector button). What is the issue here. Help would be highly appreciated

 ![](https://discuss.appium.io/uploads/default/original/2X/8/849c8533ca90b84b47b7709305544dc20942e0fd.png)

Error message as in appium window:

 ![](https://discuss.appium.io/uploads/default/original/2X/c/c9e897db647036ab8d34931ac9ccb2078ccf27d0.png)

Error log on Appium [Logs(Not able to view elements in WEBVIEW after switching context](http://www.wepaste.com/Appium%20logs/)

Do verify the capabilities which I am using before switching the context. Thanks in advance

---

<div class="post-metadata">

**Author:** ![1113](https://discuss.appium.io/user_avatar/discuss.appium.io/1113/32/2242_2.png) [@1113](https://discuss.appium.io/u/1113)\
**Post date:** [May 18, 2016, 1:20pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/2 "2016-05-18T13:20:36Z")

</div>

You should take locators for webview elements in Safari, just go to [localhost:port] (where port is ios webview debug proxy port for this device)

---

<div class="post-metadata">

**Author:** ![Suraj786](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@Suraj786](https://discuss.appium.io/u/Suraj786)\
**Post date:** [May 18, 2016, 2:02pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/4 "2016-05-18T14:02:05Z")

</div>

@1113 I tried doing that also, but no luck so far ☹

---

<div class="post-metadata">

**Author:** ![Naresh\_Karre](https://discuss.appium.io/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@Naresh\_Karre](https://discuss.appium.io/u/Naresh_Karre)\
**Post date:** [May 19, 2016, 8:24am UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/5 "2016-05-19T08:24:47Z")

</div>

Hi Suraj,

Launch the safari browser in mac PC in menu you should have Develop options.  
Click on the Develop option in that list it should list the your device.

Select your device -\> web page. (it show’s only if web page is open in phone). you will able to locate the web elements.

If you don’t see the Develop menu in the menu bar, choose Safari \>  
Preferences, click Advanced, then select “Show Develop menu in menu bar.”

Look for how to switch the webview and you need to run the ios\_webkit\_debug\_proxy.

Hope this will help you.

Regards  
Naresh

---

<div class="post-metadata">

**Author:** ![Suraj786](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@Suraj786](https://discuss.appium.io/u/Suraj786)\
**Post date:** [May 19, 2016, 10:31am UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/6 "2016-05-19T10:31:17Z")

</div>

Hi Naresh,

I did all these above steps but no help.

After setting the capabilities and launching the app I am not able to see index.html page in my safari if I use autoWebView, true in my capability

I am getting strange behaviour, If I am not using autowebview and then lauching the app then I am able to see index.html page. I suppose Appium is considering and taking my app as native app.

I even double checked this using

> driver.Context=“NATIVE\_APP”; // index.html visible  
> driver.Context=“WEBVIEW\_1”; [//index.html](https://index.html) becomes disabled and not able to click on that

Even checked through localhost:27753 and the same behaviour.

When I force appium to switch context to webview and then click it just passes that step without doing any event(click/sendkeys)

and in native view it was showing error:

**info: atom did not return yet, checking to see if we are blocked by an alert**  
**info: Pushing command to appium work queue: “au.alertIsPresent()”**

and it returns 8 commands found au.alertIsPresent()

---

<div class="post-metadata">

**Author:** ![Naresh\_Karre](https://discuss.appium.io/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@Naresh\_Karre](https://discuss.appium.io/u/Naresh_Karre)\
**Post date:** [May 19, 2016, 11:04am UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/7 "2016-05-19T11:04:13Z")

</div>

Check capabilities settings.

browser Name Safari but you gave IOS and it should be platformversion not the plaftormName.  
problem may be with capabilities.

Try to print the webview before switching after switching.

---

<div class="post-metadata">

**Author:** ![Suraj786](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@Suraj786](https://discuss.appium.io/u/Suraj786)\
**Post date:** [May 19, 2016, 11:11am UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/8 "2016-05-19T11:11:15Z")

</div>

> [@Naresh\_Karre](#):
>
> should

For hybrid app do I need to add browserName capabilities

I am using  
capabilities.SetCapability (“appium-version”, “1.4.13”);  
capabilities.SetCapability (“platformName”, “iOS”);

Am I using correct capabilities??

In addition to above two capabilities I am using below once also  
capabilities.SetCapability(“autoWebview”, “true”); // should I define true as boolean or string(in quotes)  
capabilities.SetCapability (“platformVersion”, “9.3”);  
capabilities.SetCapability(“deviceName”, “iPad Air”);  
capabilities.SetCapability(“app”, “”);  
capabilities.SetCapability(“udid”, “”);

---

<div class="post-metadata">

**Author:** ![Naresh\_Karre](https://discuss.appium.io/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@Naresh\_Karre](https://discuss.appium.io/u/Naresh_Karre)\
**Post date:** [May 19, 2016, 1:30pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/9 "2016-05-19T13:30:00Z")

</div>

Try with out setting this capability. and make sure that your are running the webkitproxy server  
capabilities.SetCapability(“autoWebview”, “true”);

---

<div class="post-metadata">

**Author:** ![Suraj786](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@Suraj786](https://discuss.appium.io/u/Suraj786)\
**Post date:** [May 19, 2016, 1:34pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/10 "2016-05-19T13:34:44Z")

</div>

> [@Naresh\_Karre](#):
>
> autoWebview

Tried but not working still ☹

---

<div class="post-metadata">

**Author:** ![Naresh\_Karre](https://discuss.appium.io/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@Naresh\_Karre](https://discuss.appium.io/u/Naresh_Karre)\
**Post date:** [May 19, 2016, 1:39pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/11 "2016-05-19T13:39:25Z")

</div>

can you copy paste all the capabilities? may be your making mistake in that.

---

<div class="post-metadata">

**Author:** ![Suraj786](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@Suraj786](https://discuss.appium.io/u/Suraj786)\
**Post date:** [May 19, 2016, 1:52pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/12 "2016-05-19T13:52:08Z")

</div>

capabilities.SetCapability (“appium-version”, “1.4.13”);  
capabilities.SetCapability (“platformName”, “iOS”);  
capabilities.SetCapability(“autoWebview”, “true”); // should I define true as boolean or string(in quotes)  
capabilities.SetCapability (“platformVersion”, “9.3”);  
capabilities.SetCapability(“deviceName”, “iPad Air”);  
capabilities.SetCapability(“app”, “”);  
capabilities.SetCapability(“udid”, “”);

I was finding the solution and came across some articles where protractor + APpium is used for automation of ionic app.

Mine is also same. Can’t we automate ionic app only using Appium.

Is it possible that Appium is not able to identify Ionic html tags??

---

<div class="post-metadata">

**Author:** ![Naresh\_Karre](https://discuss.appium.io/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@Naresh\_Karre](https://discuss.appium.io/u/Naresh_Karre)\
**Post date:** [May 19, 2016, 2:14pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/13 "2016-05-19T14:14:33Z")

</div>

Hope you are using the hybrid app ? try adding this cap.  
capabilities.setCapability(“appPackage”, “xxxxxxxxxxxxxx”);  
capabilities.setCapability(“automationName”,“Appium”);

What is the advantage of having private obj ?  
private IOSDriver driver = null;  
private DesiredCapabilities capabilities = new DesiredCapabilities();

---

<div class="post-metadata">

**Author:** ![Suraj786](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@Suraj786](https://discuss.appium.io/u/Suraj786)\
**Post date:** [May 19, 2016, 2:30pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/14 "2016-05-19T14:30:49Z")

</div>

Yes I am using hybrid ionic iOS app. Defined them private since I don’t want to use them outside the class.

Does appPackage is required for ios automation?

---

<div class="post-metadata">

**Author:** ![Naresh\_Karre](https://discuss.appium.io/letter_avatar_proxy/v4/letter/n/a88e4f/32.png) [@Naresh\_Karre](https://discuss.appium.io/u/Naresh_Karre)\
**Post date:** [May 20, 2016, 11:47am UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/15 "2016-05-20T11:47:03Z")

</div>

yes its compulsory, Read the document carefully provided by Appium.

---

<div class="post-metadata">

**Author:** ![Suraj786](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@Suraj786](https://discuss.appium.io/u/Suraj786)\
**Post date:** [May 20, 2016, 1:56pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/16 "2016-05-20T13:56:48Z")

</div>

I read and found appPackage is required only for Android on [link](http://appium.io/slate/en/master/?ruby#appium-server-capabilities). If you have any other reference, please do share.

---

<div class="post-metadata">

**Author:** ![dhanu1](https://discuss.appium.io/letter_avatar_proxy/v4/letter/d/b38774/32.png) [@dhanu1](https://discuss.appium.io/u/dhanu1)\
**Post date:** [July 20, 2018, 5:47am UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/17 "2018-07-20T05:47:25Z")

</div>

I am facing same issue . the element is present in Android but same element could not find in  
iOs how to resolve this issue.

---

<div class="post-metadata">

**Author:** ![Suraj786](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@Suraj786](https://discuss.appium.io/u/Suraj786)\
**Post date:** [July 22, 2018, 5:16pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/18 "2018-07-22T17:16:43Z")

</div>

@dhanu1 kindly ellaborate… what is xpath/environment/capabilities … This would help to resolve ur issue

---

<div class="post-metadata">

**Author:** ![dhanu1](https://discuss.appium.io/letter_avatar_proxy/v4/letter/d/b38774/32.png) [@dhanu1](https://discuss.appium.io/u/dhanu1)\
**Post date:** [July 26, 2018, 4:43am UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/19 "2018-07-26T04:43:47Z")

</div>

element is overlapp in frame so finding element is difficult .plz tell me how to find element.  
MobileElement el8 = (MobileElement) driver.findElementByAccessibilityId(“et\_lighton”);  
el8.click();

---

<div class="post-metadata">

**Author:** ![Isaias\_Silva](https://discuss.appium.io/user_avatar/discuss.appium.io/isaias_silva/32/4809_2.png) [@Isaias\_Silva](https://discuss.appium.io/u/Isaias_Silva)\
**Post date:** [October 2, 2018, 7:22pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/20 "2018-10-02T19:22:32Z")

</div>

I face the same problem … I’m using ruby.  
I have a popup that can not click at all. Application developed in IONIC (latest version).

My ENV.RB is like this … I’ve tried several ways

Before do  
def caps  
{  
caps: {  
deviceName: ‘0029179798’, # ‘emulator-5554’ Motorola Moto Z Play  
platformName: ‘Android’,  
#apk: (File.join(File.dirname( **FILE** ), ‘app-intelbras.apk’)),  
appPackage: ‘io.ionic.starter’, #com.ioasys.appprova / io.ionic.starter  
appActivity: ‘io.ionic.starter.MainActivity’, #com.appprova.core.activity.OnBoardingActivity" / io.ionic.starter.MainActivity  
newCommandTimeout: ‘3600’,  
platformVersion: ‘8.0.0’, #‘8.1.0’  
appiumVersion: ‘1.8.1’,  
deviceOrientation: ‘landscape’, #portrait  
autoWebview: true,  
# chromedriverExecutable: ‘C:/projetos/desenvolvimento/tools/drivers/chromedriver\_2.41/chromedriver.exe’,  
androidScreenshotPath: ‘results/screenshots’,  
nativeWebScreenshot: true,  
# chromedriverUseSystemExecutable: false,  
autoGrantPermissions: true,  
browserName: ‘’ #Deve usar uma string vazia se estiver automatizando um aplicativo  
},  
appium\_lib: { server\_url:SERVER\_URL, port:PORT }  
}  
end  
end

---

<div class="post-metadata">

**Author:** ![sandysandy7](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/76d3ee/32.png) [@sandysandy7](https://discuss.appium.io/u/sandysandy7)\
**Post date:** [October 8, 2018, 3:36pm UTC](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244/21 "2018-10-08T15:36:48Z")

</div>

Hi all,

I am also facing the same issue. Unable to switch to Webview from Native app in IOS. Scroll in IOS also not working.  
Doing IOS automation with xFramium tool+Appium+IOS.  
{  
“deviceName”: “iphone X”,  
“udid”: “\*\*_**",  
“platformName”: “IOS”,  
“platformVersion”: “11.4”,  
“bundleId”: "**_”,  
“automationName”: “XCUITest”  
“browserName”: “Safari”,  
“startIWDP”: “true”,  
“autoWebview”: “true”,  
“absoluteWebLocations”: “true”  
}

xFramium-Appium capabilities

 iphone X IOS false

```
<!-- DEVRY MOBILE APP -->

```

\<capability name=“appPackage” class="STRING”\>  
**\<capability name=“bundleId” class="STRING”\>** \*  
true  
false

Could anyone help out from this issue.  
Thanks

[Next page](https://discuss.appium.io/t/not-able-to-identify-element-in-webview-in-ios-hyprid-app-build-in-ionic-automation-using-appium-on-real-device/10244.md?page=2)
