Executing 'find_element' atom in default context error while trying to sendkeys in WEBVIEW of hybrid app

After launching the hybrid app build in Ionic2/Angular2/Typescript, I am changing the context using below code:

var contextNames=driver.Contexts;
driver.Context= contextNames[1]; //changing context to WEBVIEW

driver.FindElementByXPath(“locator”).Click(); //getting error on this step

After switching context I tried to use xpath from Appium inspector as well as from safari develop window

Appium Xpath = //UIAApplication1/UIAWindow1/UIAButton
Safari Xpath = //*[@placeholder=‘Username’ and @class=‘ng-untouched ng-pristine ng-valid’]

As I am working on hybrid app

  1. I installed ios_webkit_debug_proxy on mac
  2. Started the same on 27753 port
  3. In machine’s mac browser localhost:27753 gives the link
  4. Clicked on the link which displays the elements of the webview app which is currently running on connected device
  5. Took above safari xpath from here

For more details on the capabilities used and screenshot related to the error please navigate to link

Getting below error

info: [debug] [REMOTE] Executing ‘find_element’ atom in default context
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Remote debugger data sent [{“method”:“Runtime.evaluate”,“params”:{“objectGroup”:“console”,“includeCommandLineAPI”:true,“doNotPauseOnExceptionsAndMuteConsole”:true,“expression”:"(function(){return function(){function h(a){return…]

info: [debug] [REMOTE] Debugger web socket received data: {“result”:{“result”:{“type”:“string”,“value”:“{"status":0,"value":null}”},“wasThrown”:false},“id”:53}
info: [debug] Waited for 29725ms so far

Found solution:

Instead of using ionic specific tags use inner html tags for creating your xpath or use ids of inner HTML. everything will work. Thanks.