Appium只显示在科尔多瓦应用NATIVE_APP背景只显示、科尔、背景、多瓦

由网友(←═╬∞靠谱小男生~)分享简介:我在Windows上运行Appium到Android设备上直接测试科尔多瓦应用程序。然而,当我尝试获取上下文,并切换到包含的WebView (基本上,推荐过程)之一,它只返回一个上下文, NATIVE_APP 。 I'm running Appium on Windows to test a Cordova app...

我在Windows上运行Appium到Android设备上直接测试科尔多瓦应用程序。然而,当我尝试获取上下文,并切换到包含的WebView (基本上,推荐过程)之一,它只返回一个上下文, NATIVE_APP

I'm running Appium on Windows to test a Cordova app directly on an Android device. However, when I try to fetch the contexts and switch to the one containing WEBVIEW (basically, the recommended process), it only returns one context, NATIVE_APP.

在我使用的检查,我能看到的WebView 子和大量的查看儿童附加到它,这涉及到应用程序内的元件中的每一个。所以,尽管它并没有显示在web视图模式中的元素树,我能看到它的使用的WebView ,但不知何故无法连接到特定的上下文。

When I use the inspector, I'm able to see a WebView child and a lot of View children appended to it, which relate to each one of the elements inside the app. So, despite it doesn't show the element tree in Webview mode, I'm able to see it's using a WebView, but somehow isn't able to connect to that specific context.

任何关于这个想法?

推荐答案

其工作。我试图用功能的不同组合,并在-最后我找到了工作相结合。使用automationName并且不要把platformVersion的能力。

Its working. I tried with a different combinations of capabilities and at-last I found the working combination. Use automationName and dont put platformVersion in capabilities.

final File app = new File(appDir, "HybridSample.apk");
final DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "Android Emulator");
// capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("automationName", "Selendroid");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.mcc.hybrid"); // Optional
capabilities.setCapability("appActivity", ".HybridSample"); // Optional

如果你检查服务器日志,你也可以看到这一点。 可用背景:NATIVE_APP,WEBVIEW_0

If you inspect server logs, you can also see this. Available contexts: NATIVE_APP,WEBVIEW_0

这意味着,你必须如下切换上下文。

That means, you have to switch context as follows.

for (final String contextName : contextNames) {
  System.out.println(contextName);
  if (contextName.contains("WEBVIEW_0")) {
    driver.context(contextName);
  }
}

请注意,以上设置为Android超过4.4版本。如果你有奇巧或更高版本,只是删除automationName。随着automationName,将无法正常工作,因为它仅返回NATIVE_APP作为可用的上下文。

Please note that above settings are for Android version older than 4.4. If you have KitKat or later, just remove automationName. With automationName, it will not work correctly as it returns only NATIVE_APP as available context.

阅读全文

相关推荐

最新文章