Does Appium recognize xpath of hybrid apps?

I have to automate tests for an iOS hybrid app. The app is written using ionic framework. I have found the Xpath element using Safari Develop tool. And I know that the xpath is correct. And I still get this error:

org.openqa.selenium.NoSuchElementException: Can't locate an element by this strategy: Locator map: 
- native content: "By.all({By.xpath: //div[@class='nav-bar-block'][@nav-bar='active']/ion-header-bar/div/span/button})" 
- html content: "by id or name "appMenuButton""
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.47.1', revision: 'unknown', time: '2015-07-30 11:02:44'
System info: host: 'clj-mb-133', ip: '169.254.89.27', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.2', java.version: '1.8.0_65'
Driver info: driver.version: unknown

I am searching for the element with:
@iOSFindAll({@iOSFindBy(xpath = "//div[@class='nav-bar-block'][@nav-bar='active']/ion-header-bar/div/span/button";})

Am I doing something wrong? Is the xpath not working for hybrid apps?

Appium: Version 1.4.13 (Draco)
OS: Mac OS X El Capitan 10.11.2

Hope you are switching to WEBVIEW context before looking for XPATH.

Thanks,
Priyank Shah

Thank you for the reply. When you say switching to WEBVIEW context, do you refer at Appium Inspector? Or are you suggesting that Appium recognizes just xpaths that are found with Appium Inspector?

I already have the xpath. But Appium doesn’t seem to find it. What was your suggestion with the webview? Maybe I didn’t understand it.

Thank you. I should have used Appium Inspector to get the xpath, not Safari Develop. I have found the path: //UIAApplication[1]/UIAWindow[1]/UIAScrollView[2]/UIAWebView[1]/UIAButton[1] . That should work, now. Thank you again.

@alexandra.nagy
Is this issue resolved for you. I am getting similar issue in android. How did u resolved it?
please help

Even after switching to WEBVIEW ,
I’m still getting the error-
org.openqa.selenium.NoSuchElementException: Can’t locate an element by this strategy: Locator map:

  • native content: “By.chained({By.xpath: //span[text()=‘Login’]})”
  • html content: “by id or name “Loginbutton””

Please help. I’m stuck because of this