简体   繁体   English

Appium Android测试-位置问题

[英]Appium Android test - location problems

I want to test an android app with appium. 我想用appium测试一个android应用。 The app is using Google Maps to show the current location. 该应用程序正在使用Google Maps显示当前位置。 It's important for the app, that it starts directly at a certain location, otherwise it blocks and gives a message, that the app isn't available at the current location. 对于应用程序而言重要的是,它必须直接在某个特定位置启动,否则会阻止并发出一条消息,表明该应用程序在当前位置不可用。

Even if I set the location with Appium directly after starting the app, the app blocks as I explained previously. 即使我在启动应用程序后直接通过Appium设置了位置,该应用程序也会按照我之前的说明进行阻止。 The location is set properly in the current location, but I guess the Google Maps cache is resetted (or something like that) and it starts at a wrong location. 该位置已在当前位置正确设置,但我想Google Maps缓存已重置(或类似的设置),并且从错误的位置开始。

When I test the app manually in the same emulator, I can open the app and it works without problems. 当我在同一模拟器中手动测试该应用程序时,我可以打开该应用程序,它可以正常运行。 The Google Maps shows directly the location that I set. Google地图直接显示了我设置的位置。 This problem only occurs when the app is started with Appium. 仅当使用Appium启动应用程序时,才会出现此问题。

Any ideas? 有任何想法吗? Thank you very much! 非常感谢你!

Without Appium server logs it is unclear if service succeed to change location. 如果没有Appium服务器日志,则不清楚服务是否成功更改位置。 Make sure you are setting location correctly : 确保正确设置位置:

driver.setLocation(location);

where location is instance of Location (double latitude, double longitude, double altitude) 其中location是Location的实例(双纬度,双经度,双海拔)

In addition, you may try to toggle location on/off before actually setting value: 另外,您可以尝试在实际设置值之前打开/关闭位置:

driver.toggleLocationServices();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM