2016-07-25 64 views

回答

2

您似乎在尋找有關混合應用(包括帶有移動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 –

相關問題