java - 使用 Appium 和 Selenium WebDriver 在不重置其状态的情况下测试 Android 应用程序

标签 java android selenium-webdriver appium

我希望在不重置其状态的情况下测试我的 android 应用程序。我注意到每次运行该应用程序时都会出现不同的弹出窗口,因此我希望记录所有不同的弹出窗口。

我在这里对“运行”的定义是点击手机上的后退按钮,然后再次点击我的应用程序图标。

但是,我无法在我的 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)

有没有办法用代码的形式模拟物理点击图标?我知道我们可以设置坐标,但我不想将我的测试硬编码为仅在手机的特定实例上运行。如果卸载其他应用程序并且我的应用程序图标移动到另一个位置,它将不会运行。

最佳答案

这对我有用:

"appPackage": "com.company.app",
"appActivity": "com.company.app.activities.HomeActivity",
"skipDeviceInitialization": true,
"skipServerInstallation": true,
"noReset": true

这不会重新安装 .apk、appium 服务器,也不会删除 appdata。在开始测试之前,您可以像离开时一样启动该应用。

我发现这个在 GitHub 上浏览相同的问题:

https://github.com/appium/appium/issues/4955

https://github.com/appium/appium/issues/3783

关于java - 使用 Appium 和 Selenium WebDriver 在不重置其状态的情况下测试 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37781823/

相关文章:

java - 尝试用 Java 解析 XML 文件并将变量存储在 ArrayList 中

android - 旋转的 OpenStreetMap View - 如何在 Android 中旋转后沿手指移动方向滑动 map ?

android - android webview 的 TargetDpi 替代品

java - org.openqa.selenium.remote.internal.ApacheHttpClient 在 Selenium 3.14.0 中被弃用 - 应该使用什么来代替?

java - 类 "Department"已映射,但未包含在任何持久性单元中

java - "Location is required"加载FXML文件时出现异常

java - 如何实现检查 Intent 是否正在运行或关闭的条件?

android - 我可以在我的 Android 工作室的项目资源管理器中隐藏某些文件和文件夹吗?

java - 将 Selenium WebDriver 与 Tor 一起使用

javascript - 如果复选框没有 "checked"属性,如何检查它的状态?