如何在Appium中设置假GPS位置



我看到有一种方法可以设置Locationdriver.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-shell.

最后,对于iOS,你可以使用XCode中的假位置运行配置,但我还没有找到任何方法来用Appium自动化中的假定位程序运行应用程序。

最新更新