如何在 Appium 中为 iOS 自动化启用和使用 WebView [英] How to enable and use WebView for iOS Automation in Appium

查看:53
本文介绍了如何在 Appium 中为 iOS 自动化启用和使用 WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用由 Ionic2/Angular2/Typescript 开发的 Appium 自动化混合应用程序.

I am trying to automate hybrid app using Appium developed by Ionic2/Angular2/Typescript.

当我尝试识别元素时,我可以在 Appium Inspector 的 WebView 中看到元素,但是当我尝试使用脚本识别它们时,它抛出错误.

When I am trying to identify element I am able to see element in WebView in Appium Inspector but when I try to identify them using script it is throwing error.

An element could not be identified using given search parameter.

error: Invalid locator strategy: partial link text

我正在尝试通过 Xpath、名称、linkText 识别 elemnet,但我无法这样做.

I am trying to identify elemnet through Xpath, name, linkText but I am not able to do so.

我还通过添加在功能中启用了 webview

I also enable webview in capabilities by adding

capabilities.SetCapability("autoWebView", "true");

我使用 C# 进行自动化.谁能提供解决方案?

I am using C# for automating. Can anybody provide the solution?

当我使用 Xpath 时,它显示处理命令时发生未知的服务器端错误(原始错误:connect ECONNREFUSED)

When I use Xpath it shows An unknown server side error occured while processing the command (Original error: connect ECONNREFUSED)

在设置上述功能后调用var contextNames= driver.Contexts;时会显示上述错误.我还需要为浏览器设置功能吗???

Above error is displayed when I call var contextNames= driver.Contexts; after setting the above capability. Do I also need to set capability for browser???

推荐答案

即使使用后

capabilities.SetCapability("autoWebView", "true");

我们需要访问代理来处理webview

We need to access proxy to handle webview

Set<String> contextNames = idriver.getContextHandles();

    System.out.println(contextNames);

    for (String contextName : contextNames) {
      if (contextName.contains("NATIVE_APP")) {
        Reporter.log("Reaching to Native App", true);
        idriver.context(contextName);
        idriver.findElementByName("Open").click();
        Reporter.log("Clicking Open to naviagte to Native APP", true);
      }
      else{
        Reporter.log("Not found", true);
      }
    }

或者尝试使用代理来处理 webview——只是一个黑客

or try to ru proxy to handle webview -- just a hack

Ru 在终端下面

ios_webkit_debug_proxy -c abad62540cbfc9f2af5c154985420a856e:27753 -d

这篇关于如何在 Appium 中为 iOS 自动化启用和使用 WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆