尝试使用Appium在混合应用程序的WEBVIEW中发送密钥时,在默认上下文错误中执行'find_element'原子

时间:2016-05-18 15:01:02

标签: automation appium hybrid-mobile-app inspector appium-ios

在Ionic2 / Angular2 / Typescript中启动混合应用程序构建之后,我正在使用以下代码更改上下文:

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

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

切换上下文后,我尝试使用Appium检查器的xpath以及safari开发窗口

Appium Xpath = // UIAApplication 1 / UIAWindow 1 / UIAButton [2] Safari Xpath = // * [@ placeholder ='Username'和@ class ='ng-untouched ng-pristine ng-valid']

正在处理混合应用程序

   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

有关所用功能的详细信息以及与错误相关的屏幕截图,请导航至link

获得以下错误

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

1 个答案:

答案 0 :(得分: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);
    }
}