2016-06-13 26 views
0

我希望在不重置其狀態的情況下測試我的android應用程序。我注意到每次運行應用程序時都會出現不同的彈出窗口,所以我希望記錄所有的彈出窗口。Android應用程序的測試,無需使用Appium和Selenium重置其狀態WebDriver

我在這裏定義的「運行」是點擊手機上的後退按鈕並再次點擊我的應用程序圖標。

但是,我無法在我的Appium測試中模擬手機的這種物理攻擊。我可以退出第一次測試,但我無法再次重新打開我的應用程序。

事情我已經試過(用我的手指上的應用程序圖標攻模擬):

1. Setting noReset to true in capabilities setting 

2. Using uiautomator to find my application. However, uiautomator doesn't seem to be able to detect any icons in the app menu page. It just shows many layers of frame layouts. 

3. closeApp() and launchApp() resets the application and this defeats the purpose of my test. My application somehow behaves differently with each run so I hope to run my test in a single session (i.e. closing and opening the application while it is still in the same state) 

反正我有可以模擬圖標的物理攻中的代碼的形式?我知道我們可以設置座標,但我不想將測試硬編碼爲只在手機的特定實例上運行。如果卸載了其他應用程序並且我的應用程序圖標轉移到另一個位置,它將不會運行。

回答

0

如果我沒有得到你錯在這裏,你可以使用AndroidDriver嘗試使用以下組合:

driver.navigate().back(); // from app home screen to mobile home screen 
driver.startActivity(String appPackage, String appActivity); // or possibly cast ((AndroidDriver)driver) 
+0

我的代碼無法找到函數startActivity。你使用哪些庫?我正在使用java-client:4.0.0和selenium 2.53.0 – ykw

+0

@ykw - 如上所述,該方法與AndroidDriver相關聯,您使用的驅動程序是什麼? – nullpointer

+0

噢,是的...我使用的是AppiumDriver。抱歉。 AppiumDriver和AndroidDriver有什麼區別? :P – ykw

0

您可以通過給包名啓動應用程序,並在啓動活動名稱,而不是apk文件的這種方式你的應用程序將不會被重置,每次你的啓動應用程序 電子表格使用presskey4點擊後退按鈕,你可以調用啓動應用程序功能啓動應用程序無需重置

相關問題