Sni*_*ack 10 c# gps selenium-chromedriver
How can I fake/mock the Geolocation in the ChromeDriver through Selenium in C#?
我只有 Python 和 Java 的示例,但我无法将代码“翻译”为 C#,因为使用的函数不存在。
这是我想要做的示例图像:
官方说好像还不支持。 https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation
我在这里可以想到两个选择
localState。请注意,您无法在运行时更改它。https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md https://chromedriver.chromium.org/capability
self.driver.set_location(49, 123, 10)
Run Code Online (Sandbox Code Playgroud)
driver.Location.Altitude = 94.23;
driver.Location.Latitude = 121.21;
driver.Location.Longitude = 11.56;
Run Code Online (Sandbox Code Playgroud)
http://appium.io/docs/en/commands/session/geolocation/set-geolocation/
随时更改位置。我认为无论如何这是最好的方法,即使使用 Chrome 而不是配置 Appium 服务器更容易。