如何使用selenium打开chrome浏览器

问题描述 投票:0回答:0

我需要一个打开 chrome 浏览器的基本代码,但该代码不起作用 我的chrome版本是版本123.0.6312.106(官方版本)(64位) https://chromedriver.chromium.org/downloads 没有特定于我的版本的 chromedriver,但有一个测试 chrome 我尝试同时使用两者。 有人可以指导我完成这个吗,我是这个硒的初学者

from selenium import webdriver chromepath = r"C:\Users\hp\Desktop\Automation\chromedriver.exe" driver = webdriver.Chrome(chromepath) driver.get('http://www.google.com')

我尝试了上述方法但不起作用 显示错误:AttributeError:'str'对象没有属性'capability'

from selenium import webdriver driver = webdriver.Chrome() driver.get('http://www.google.com')

但是当我将路径添加为系统变量时,chrome 会打开一秒钟然后关闭

显示错误:在 C:\Users\hp\Desktop\Automatio 的 PATH 中检测到 chromedriver 版本 (114.0.5735.90)

python selenium-webdriver selenium-chromedriver
© www.soinside.com 2019 - 2024. All rights reserved.