如何使用appium驱动程序在android应用程序中自动执行移动版本页面

问题描述:

我正在测试使用appium的android应用程序。 在那几个应用程序重定向到移动版本页面的链接。 我使用Google搜索,但没有得到正确的解决方案,我想知道如何找到元素并在移动版本页面上执行操作。 在此先感谢....!如何使用appium驱动程序在android应用程序中自动执行移动版本页面

您似乎在寻找有关混合应用(包括带有移动Web内容的WebViews的本机应用)自动化测试的信息。

的Appium API参考是一个很好的资源,以获取有关混合动力的应用程序自动化的基本信息:http://appium.io/slate/en/master/?java#automating-hybrid-apps

的主要区别与网页视图工作时是,你需要改变的webdriver,以配合的情况下您希望检查或自动化的WebView。还要注意,一旦回到检查和自动化实际的本地应用程序,上下文应该被设置回NATIVE_APP。

// java 
// assuming we have a set of capabilities 
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); 

Set<String> contextNames = driver.getContextHandles(); 
for (String contextName : contextNames) { 
    System.out.println(contextNames); //prints out something like NATIVE_APP \n WEBVIEW_1 
} 
driver.context(contextNames.toArray()[1]); // set context to WEBVIEW_1 

//do some web testing 
String myText = driver.findElement(By.cssSelector(".green_button")).click(); 

driver.context("NATIVE_APP"); 

// do more native testing if we want 

driver.quit(); 
+0

感谢您的回答....!如果可能的话,请添加几行代码以供参考 –

+0

您是否正在使用某种特定语言?我提供的链接在页面的右侧为Appium的所有常用语言提供了代码片段。从右上角选择语言。 – Domestus

+0

是的,它在那里得到它谢谢你太多.... @ Domestus –