【问题标题】:Access geolocation with Selenium WebDriver, Chrome, and macOS使用 Selenium WebDriver、Chrome 和 macOS 访问地理位置
【发布时间】:2021-11-22 05:38:22
【问题描述】:

我想运行测试以使用 Selenium WebDriver(版本 4.0.0-rc-1)访问地理位置坐标:

https://github.com/bonigarcia/selenium-webdriver-java/blob/master/selenium-webdriver-junit5/src/test/java/io/github/bonigarcia/webdriver/jupiter/ch5/caps/geolocation/GeolocationChromeJupiterTest.java

我在 GitHub Actions 上运行此测试,它在 ubuntu-latest (Ubuntu 20.04)、windows-latest (Windows Server 2019) 上运行良好,但在 macos-latest (macOS 10.15) 上运行良好。 Mac 中的 Chrome 似乎无法访问地理位置数据:

有没有人知道是否可以实现?

【问题讨论】:

  • 确保在浏览器中启用地理定位。 BTW selenium 默认使用一个临时的浏览器配置文件,它可以有不同的设置。

标签: java macos selenium-webdriver geolocation github-actions


【解决方案1】:

我找到了解决方案。我在这里发帖以防万一它对某人有帮助。在macOS的偏好设置中,我们需要为Chrome开启定位服务(系统偏好设置->安全与隐私->定位服务),如下:

之后,测试就可以访问位置坐标了。

【讨论】:

    猜你喜欢
    • 2019-03-21
    • 2016-09-20
    • 1970-01-01
    • 1970-01-01
    • 2020-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多