We are having issue in Identifying Xpath with appium Latest Version

Hi Team,

We are actually trying to automate the APP in our org and we have successfully done with the configuration of Appium using XCUITEST and we are able to launch the app in real device.

Now actually our app is developed in angular and the code base is same for IOS, Browser and Android.

Issue that we are facing is when we try to inspect the element in appium it always shows up the xpath that is native in nature like XCUIElement kind of , but in browser and other tool like seetest is able to find the xpath in xml way like class, id, text. when we tried using this xml kind of xpath appium fails.

Can anyone help us in making normal xpath work.

Example Xpath found in browser : xpath=//*[@id=‘home-page-pending-pickcount-pickup-2’]
How to make this xpath work in appium as this ID is given my our devolopment team and this is not showed in Appium inspector.

@Kiran_Bn steps:

  1. run your app in appium code
  2. with any screen execute:
  1. check output and find any element your need


We did that and i got the Page Source from appium, but there is a difference between the source that is shown in Appium and source showed in chrome browser for the same app.

For Example :

According to appium this is the xpath for my app : //XCUIElementTypeTextField[@value=‘Username’]
In browser/Seetest tool the Xpath for same element id like this : //*[@id=‘login-username’]

Now the question is how there are 2 xpaths for same element , same app, just that the tool is different. I guess that the appium is getting the NATIVE Xpath.

Is there an option to make the browser xpath work with some change in appium capabilities.

@Kiran_Bn if Appium with your app in Native you can always try to switch into WEB view forcibly.


Thanks for the quick response.

I have already tried the below :

contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
println contextNames;

The above code always shows the set to be [NATIVE_APP].

Can you please tell me how to switch to WEB view forcibly. This will help us a lot.

@Kiran_Bn can you share at https://gist.github.com/ your driver.getPageSource ?


I have added the Page Source showed in appium.

I have take the source of the page (Original)

In both source we can see that the Username and password field showed in Appium inspector and the page source original is different.

Actually our dev have given the id’s to the element the problem is we cannot use that as its not showing up in appium and hence not working also if forcibly tried with the xpath with id.

@Kiran_Bn so get Username:

MobileElement el = driver.findElement(MobileBy.iOSNsPredicateString(“type == ‘XCUIElementTypeTextField’ AND value == 'Username’ AND visible == 1”)) // name is ID in most cases
// or just
MobileElement el = driver.findElement(MobileBy.iOSNsPredicateString(“type == ‘XCUIElementTypeTextField’ AND visible == 1”)); // name is ID in most cases

tap login:

driver.findElement(MobileBy.iOSNsPredicateString(“type == ‘XCUIElementTypeButton’ AND name == 'Log in’ AND visible == 1”)).click();


Yeah i used something like this :
driver.findElement(By.xpath("//XCUIElementTypeTextField[@value=‘Username’]")).sendKeys("[email protected]");

and it works fine.

Now there are some page for example i have attached page source, there is no ID for the edit box according to appium but i can use class according to browser xpath.

Here there is XCUIElementTypeTextField but no properties according to appium, but i have written xpath like this to make it work like below :

driver.findElementByXPath(".//*[@name=‘Server URL’]/ancestor::XCUIElementTypeOther[1]/following-sibling::XCUIElementTypeOther[1]/XCUIElementTypeTextField").sendKeys(“23-xy-dev.com”);

The above xpath works fine but browser says this xpath which seems to be more meaningfull //*[@id=‘authUrl’]/input[@hidden=‘false’]

Please let me know your thoughts here.

@Kiran_Bn just ask iOS dev add AccesibilityIDs to elements (i do it myself in iOS code all the time)


The problem that we are facing is they are telling that they have provided the ID’s, class uniquely for the element, as appium is showing only Native elements only we cant use it.

And we are QA Automation engineers and we dont have the source code with us to change. We have just the debug enabled ipa , apk.

I tried using the ios_webkit_proxy and added the desired capabilities in appium scripts but appium iam getting message as no Webview found and its retrying.

The only question i have is if there is a option in appium/wda to make normal xpath work as other tools are showing the xpaths in normal way (Like we are analyzing Seetest) which actually xml instead of Native.

Also we need to use the script for runnning in iOS, Android and Browser, i dont know if i use this Native xpath, it will work in all 3 devices.

Please let me know ur suggestions.


Please let me know if there is any solution for the above, we are facing lot of issues in identifying elements with normal xpath.


1 Like

@Kiran_Bn sorry. never worked with Angular…


I dont think its anything to do with Angular, as there is no NG elements in our application, if there is a way to switch to Webview in appium forcefully then it should be able to identify the normal html Xpaths. But i dont see any way to switch it in appium.

@Kiran_Bn checked our app. zero problems.

example of code:

        for(Object context : driver.getContextHandles()) {
            System.out.println("Context Name is " + context.toString());

Result of output for one element (just some random element choosen from pagesource):

Context Name is NATIVE_APP
                                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="4" y="376" width="367" height="179">
                                  <XCUIElementTypeLink type="XCUIElementTypeLink" name="Contactless MasterCard" label="Contactless MasterCard" enabled="true" visible="true" x="112" y="499" width="151" height="19">
                                    <XCUIElementTypeLink type="XCUIElementTypeLink" value="2" name="Contactless MasterCard" label="Contactless MasterCard" enabled="true" visible="true" x="112" y="499" width="151" height="19">
                                      <XCUIElementTypeLink type="XCUIElementTypeLink" value="2" name="Contactless MasterCard" label="Contactless MasterCard" enabled="true" visible="true" x="112" y="499" width="151" height="19">
                                        <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="2" name="Contactless MasterCard" label="Contactless MasterCard" enabled="true" visible="true" x="112" y="499" width="151" height="19"/>

Context Name is WEBVIEW_99252.1
<li class="col-xs-12 col-sm-4 col-md-3">
												<div class="list-gutter__item">
													<div class="card">
														<a href="https://xxxxxxxxx/contactless-mastercard/" class="card-bordered-url text-center card-bordered-url-lg" data-mh="support-category" style="">
															<h2 class="text-normal text-gray-base title-icon icon__contactless-card">Contactless MasterCard</h2>

Hi @Aleksei

Thanks for the above example.

Actually i had a discussion with my dev, our app is devoloped in corodova framework and the problem is the appium is not able to find the webviews and there has been issues previosly also with corodova apps with appium, i have tried using the ios-webkit-proxy, with that also i get the same message no webframes found.

Tried a lot but still not able to get the solution.

@Kiran_Bn Appium for iOS uses https://github.com/facebook/WebDriverAgent . the issue is inside it.

Hi @Aleksei,

Is there anything that i can do in WebdriverAgent ?? so that appium gets the webview context.

I tried creating simple hello world Corodova app and there also its not able to identify the webviews, so its not the problem with the ipa/app file.

Or you are saying that its a known issue with corodova apps.

If there is anything that can be done in webdriver agent then i can try it please do suggest.

@Kiran_Bn maybe you can share “app” file for simulator i will try…

Hi @Aleksei,

There is some issue with our app with simulators its crashing only works with Real device.

Shall i attach the the Helloworld Corodova ipa, its also same issue.

Let me know how to share the ipa as well.