[英]Testing of Android Application without resetting its state using Appium and Selenium WebDriver
I wish to test my android application without resetting its state. 我希望在不重置其状态的情况下对其进行测试。 I noticed that different popups appear everytime I run the application so I wish to log all the various popups.
我注意到每次运行该应用程序时都会出现不同的弹出窗口,因此我希望记录所有各种弹出窗口。
My definition of "run" here is tapping the back button on my phone and tapping my application icon again. 我对“运行”的定义是点击手机上的后退按钮,然后再次点击应用程序图标。
However, I am unable to simulate this physical tapping of the phone on my Appium test. 但是,我无法在Appium测试中模拟手机的这种物理敲击。 I can exit my first test but I am unable to reopen my application again.
我可以退出第一个测试,但是无法再次打开我的应用程序。 (Simulation of tapping on the application icon with my finger)
(用手指点击应用程序图标的模拟)
Things I have tried: 我尝试过的事情:
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)
Is there anyway I can simulate the physical tapping of the icon in the form of code? 无论如何,我可以通过代码形式模拟图标的物理点击吗? I know we can set the coordinates but I don't want to hard code my test to run only on a specific instance of the phone.
我知道我们可以设置坐标,但是我不想对测试进行硬编码以仅在特定的手机实例上运行。 It will not run if other applications are uninstalled and my application icon shifts to another position.
如果卸载了其他应用程序并且我的应用程序图标移至另一个位置,它将无法运行。
This worked for me: 这为我工作:
"appPackage": "com.company.app",
"appActivity": "com.company.app.activities.HomeActivity",
"skipDeviceInitialization": true,
"skipServerInstallation": true,
"noReset": true
This won't reinstall the .apk, appium server and it won't delete the appdata. 这不会重新安装.apk,appium服务器,也不会删除appdata。 You can just start the app like you've left it before starting the test.
您可以像退出测试之前一样离开它来启动应用程序。
I found this browsing the same issues on GitHub: 我发现这在GitHub上浏览了相同的问题:
https://github.com/appium/appium/issues/4955 https://github.com/appium/appium/issues/4955
https://github.com/appium/appium/issues/3783 https://github.com/appium/appium/issues/3783
If I am not getting you wrong here, you can try using a combination of following using AndroidDriver
: 如果我在这里没弄错,您可以尝试使用以下结合使用
AndroidDriver
:
driver.navigate().back(); // from app home screen to mobile home screen
driver.startActivity(String appPackage, String appActivity); // or possibly cast ((AndroidDriver)driver)
您可以通过提供程序包名称和启动活动名称(而不是大写的apk文件)来启动应用程序,这样,您每次启动应用程序时都不会重置您的应用程序,因为使用presskey4轻击后退按钮时,您可以调用启动应用功能,无需重置即可启动应用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.