1

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[2] 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
4

1 回答 1

0

尝试将上下文更改为 NATIVE 然后切换回 WEBVIEW

/* Code for context to find the View used in application */
Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
    System.out.println(contextName);
    if (contextName.contains("WEBVIEW")){
    driver.context(contextName);
    }
}
于 2016-05-18T15:58:03.123 回答