当前位置:   article > 正文

selenium学习日记(一)_unable to obtain driver for chrome using selenium

unable to obtain driver for chrome using selenium manager

selenium:web自动化测试框架
使用软件:pycharm ce
语言:python

1,selenium简介:
Selenium是一个用于Web应用程序测试的工具,是一套完整的web应用程序测试系统

2,终端安装selenium:

pip install selenium
  • 1

使用国内源:

pip install selenium -i https://pypi.douban.com/simple/
  • 1

3,安装web driver后,运行报错:
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
推测为web driver版本和浏览器版本不一致导致
谷歌浏览器版本为115,但是下载链接里面只有114的,下载之后导致运行错误

4/重新下载安装了115的版本
终端输入命令

chromedriver -v
  • 1

发现获取不到版本号,进入bin目录:

cd /usr/local/bin
  • 1

输入命令:

xattr -d com.apple.quarantine chromedriver
  • 1

再次查询版本号,显示当前版本为115
ChromeDriver 115.0.5790.170 (cc0d30c2ca5577520c8646671513241faa0bc105-refs/branch-heads/5790@{#1923})

5.pycharm 中运行脚本
还是报错
elenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

6.然后检查了python解释器版本,
通过which python3查询当前python解释器路径
然后在pycharm中修改python解释器

7/再次运行:

from selenium import webdriver
chr = webdriver.Chrome()
chr.get('https://www.baidu.com')
  • 1
  • 2
  • 3

成功打开了百度页面,没有报错,但是打开完了闪退

8降低selenium版本

pip3 install selenium==4.4.3
  • 1

9.再次运行程序,成功打开浏览器没有闪退

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/302767
推荐阅读
相关标签
  

闽ICP备14008679号