selenium安装谷歌浏览器驱动仍然无法打开浏览器的问题处理
想利用这个例子简单测试一下安装是否成功?
from selenium import wbdriver
driver = weddriver.Chrom()
driver.get(‘http://www.baidu.com’)
前提是:浏览器版本和浏览器驱动版本是一致的,具体怎么看版本是否是一致的,下期再给大家补充
结果报如下错误:文章来源:https://www.toymoban.com/news/detail-507278.html
Traceback (most recent call last):
File "D:\pythoncode\pythonProject\study\unitest框架及执行顺序\测试安装是否成功.py", line 3, in <module>
driver = webdriver.Chrome()
File "C:\Program Files (x86)\Python310-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "C:\Program Files (x86)\Python310-32\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 92, in __init__
super().__init__(
File "C:\Program Files (x86)\Python310-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 277, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Program Files (x86)\Python310-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 370, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Program Files (x86)\Python310-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 435, in execute
self.error_handler.check_response(response)
File "C:\Program Files (x86)\Python310-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
Stacktrace:
Backtrace:
Ordinal0 [0x00CCC013+3194899]
Ordinal0 [0x00BB6021+2056225]
Ordinal0 [0x00A4F608+587272]
Ordinal0 [0x009CD87E+55422]
Ordinal0 [0x009CC64A+50762]
Ordinal0 [0x009F1EE9+204521]
Ordinal0 [0x009F1D0D+204045]
Ordinal0 [0x009EFC1B+195611]
Ordinal0 [0x009D3B7F+80767]
Ordinal0 [0x009D4B4E+84814]
Ordinal0 [0x009D4AD9+84697]
Ordinal0 [0x00BCCE64+2149988]
GetHandleVerifier [0x00E3BE95+1400773]
GetHandleVerifier [0x00E3BB61+1399953]
GetHandleVerifier [0x00E431FA+1430314]
GetHandleVerifier [0x00E3C69F+1402831]
Ordinal0 [0x00BC3D61+2112865]
Ordinal0 [0x00BCE5CB+2155979]
Ordinal0 [0x00BCE6F5+2156277]
Ordinal0 [0x00BDF26E+2224750]
BaseThreadInitThunk [0x7516FA29+25]
RtlGetAppContainerNamedObjectPath [0x77197A9E+286]
RtlGetAppContainerNamedObjectPath [0x77197A6E+238]
就在网上找了各种帖子,都没有一个明确的结果,不是让检查浏览器版本和驱动版本就是说代码有问题,但是在其他同事那代码能正常运行
结果就看了一下webdriver.py这个文件的内容,浏览器的名字必须要等于chrome,否则找不到,代码如下:
在安装浏览器的时候浏览器的名字都是默认的,大家往往会忽视这一点,我的浏览器的名字是:Chromium.exe,所以就需要把浏览器应用复制一份进行重命名,如图:
然后再运行之前的代码就能正常启动浏览器了~~~
如果有其他问题,欢迎给博主留言哦文章来源地址https://www.toymoban.com/news/detail-507278.html
到了这里,关于selenium无法打开浏览器问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!