首页 > 解决方案 > 如何在 Appium 中设置假 GPS 位置

问题描述

我看到有设置位置的方法driver.setLocation(Location); 但是我需要哪个驱动程序呢?这适用于 Android 和 iOS 吗?

标签: seleniumautomationappium

解决方案


对于最容易配置的模拟器或模拟器,请使用以下功能。

安卓

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 自动化的假位置来运行应用程序。


推荐阅读