How can I fake/mock the Geolocation in the ChromeDriver through Selenium in C#?(如何通过 C# 中的 Selenium 伪造/模拟 ChromeDriver 中的地理位置?)
问题描述
如何在 C# 中通过 Selenium 伪造/模拟 ChromeDriver 中的地理位置?
How can I fake/mock the Geolocation in the ChromeDriver through Selenium in C#?
我只是 Python 和 Java 的示例,但我无法将代码翻译"为 C#,因为使用的函数不存在.
I only examples for Python and Java but I cannot "translate" the code to C# because the used functions do not exist.
这是我想要做的示例图片:
This is a example image of what I want to do:
推荐答案
官方说好像还不支持.https://sites.google.com/a/chromium.org/chromedriver/移动仿真
我可以在这里想到 2 个选项
I can think of 2 options here
- 使用
localState
功能尝试使用 Chrome 状态文件查找是否可能.请注意,您无法在运行时更改它.
- Try and find if it possible using Chrome State file, using
localState
capability. Note, you cannot change it on runtime.
https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.mdhttps://chromedriver.chromium.org/capabilities
- 用真实/模拟器设备设置Appium驱动并使用
self.driver.set_location(49, 123, 10)
driver.Location.Altitude = 94.23;
driver.Location.Latitude = 121.21;
driver.Location.Longitude = 11.56;
http://appium.io/docs/en/命令/会话/地理位置/设置地理位置/
随时更改位置.我认为无论如何这是最好的方法,即使只使用 Chrome 而不是配置 Appium 服务器更容易.
To change the location whenever you like. I think this is the best way to do it anyway, even if it is easier to just use Chrome instead of configure Appium server.
这篇关于如何通过 C# 中的 Selenium 伪造/模拟 ChromeDriver 中的地理位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何通过 C# 中的 Selenium 伪造/模拟 ChromeDriver 中的地理位置?


- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 输入按键事件处理程序 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01