selenium - 如何在 Appium 中设置假 GPS 位置
问题描述
我看到有设置位置的方法driver.setLocation(Location);
但是我需要哪个驱动程序呢?这适用于 Android 和 iOS 吗?
解决方案
对于最容易配置的模拟器或模拟器,请使用以下功能。
安卓
gpsEnabled: true
iOS
locationServicesEnabled: true
locationServicesAuthorized: true
需要提供bundleId
后者工作的能力。
对于真实的设备,事情会更加棘手。在 Android 中,您应该能够在开发人员设置中启用模拟位置,但是,我无法使用 AppiumsetLocation
方法将其投入使用。这个问题通过 adb 调用 Appium 设置应用程序可能会在这方面对您有所帮助:https ://android.stackexchange.com/questions/35716/is-it-possible-to-set-devices-latitude-and-longitude-using-adb -外壳。
最后,对于 iOS,您可以使用带有来自 XCode 的假位置的运行配置,但我还没有找到任何方法来以编程方式使用来自 Appium 自动化的假位置来运行应用程序。
推荐阅读
- python - 如何不断显示随机数tkinter
- rust - 如何在 cargo.toml 文件中将特定版本的依赖项列入黑名单?
- python - Pandas 复制列元素并根据相关列表应用于另一列
- php - 如何在laravel中制定导航栏链接到其页面?
- azure - Azure 服务总线 AMQP 对象接收器已中止
- python - 如何在设置和创建时自动生成 sqlalchemy 关系?
- ios - 为什么无法将 `(()->Void)` 转换为 `(()->Void)?
- java - Liskov 的替换原则如何适用于 Object 等类?
- reactjs - 如何引起对重新渲染复选框的反应
- swift - 在 SwiftUI 中单击按钮时创建重复计数器