1
我正在測試使用appium的android應用程序。 在那幾個應用程序重定向到移動版本頁面的鏈接。 我使用Google搜索,但沒有得到正確的解決方案,我想知道如何找到元素並在移動版本頁面上執行操作。 在此先感謝....!如何使用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();
感謝您的回答....!如果可能的話,請添加幾行代碼以供參考 –
您是否正在使用某種特定語言?我提供的鏈接在頁面的右側爲Appium的所有常用語言提供了代碼片段。從右上角選擇語言。 – Domestus
是的,它在那裏得到它謝謝你太多.... @ Domestus –