使用selenium学习UI自动化测试时遇到的第一个问题:
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
。
从网上找了各个大神的回复,发现问题就是需要安装geckodriver,将geckodriver拷贝到firefox的安装目录,并配置环境变量Path即可,
1、问题一;geckodriver 和firefox的映射版本是什么??
参考链接:https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html
Supported platforms
The following table shows a mapping between geckodriver releases, and required versions of Selenium and Firefox:
geckodriver | Selenium | Firefox | |
---|---|---|---|
min | max | ||
0.29.1 | ≥ 3.11 (3.14 Python) | 60 | n/a |
0.29.0 | ≥ 3.11 (3.14 Python) | 60 | n/a |
0.28.0 | ≥ 3.11 (3.14 Python) | 60 | n/a |
0.27.0 | ≥ 3.11 (3.14 Python) | 60 | n/a |
0.26.0 | ≥ 3.11 (3.14 Python) | 60 | n/a |
0.25.0 | ≥ 3.11 (3.14 Python) | 57 | n/a |
0.24.0 | ≥ 3.11 (3.14 Python) | 57 | 79 |
0.23.0 | ≥ 3.11 (3.14 Python) | 57 | 79 |
0.22.0 | ≥ 3.11 (3.14 Python) | 57 | 79 |
0.21.0 | ≥ 3.11 (3.14 Python) | 57 | 79 |
0.20.1 | ≥ 3.5 | 55 | 62 |
0.20.0 | ≥ 3.5 | 55 | 62 |
0.19.1 | ≥ 3.5 | 55 | 62 |
0.19.0 | ≥ 3.5 | 55 | 62 |
0.18.0 | ≥ 3.4 | 53 | 62 |
0.17.0 | ≥ 3.4 | 52 | 62 |
我用的浏览器的版本是90版本如下:
所以下载最新的geckodriver : 0.29.1
下载地址:
https://github.com/mozilla/geckodriver/releases
下载完成后解压,将geckodriver.exe文件拷贝到firefox的安装目录中,比如我的安装目录是 D:\Program Files\Mozilla Firefox
然后将 D:\Program Files\Mozilla Firefox 添加到系统和administrator的环境变量中,注意两个地方都要添加:
添加完成后将pycharm 重启,再执行代码即可通过
参考链接:
https://www.cnblogs.com/levia/p/14885089.html
https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html
https://www.newbe.pro/Mirrors/Mirrors-GeckoDriver/
https://cloud.tencent.com/developer/article/1443818?from=article.detail.1653345