手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

Ubuntu下如何安装ChromeDriver

时间:2024-10-13 17:23:16

1、启动Chrome浏览器,验证chorme是否安装正确hxb@omg:~$ which google-chrome/usr/bin/google-chromehxb@omg:~$ google-chrome这时候如果安装正确可以看到系统打开chrome浏览器了

Ubuntu下如何安装ChromeDriver
Ubuntu下如何安装ChromeDriver

2、检查系统是否已经安装了ChromeDriver,通过which ChromeDriver命令可以查看,如果安装了就可以找到安装路径hxb@omg:~$ which ChromeDriverhxb@omg:~$没有显示说明系统未安装ChromeDriver

Ubuntu下如何安装ChromeDriver

3、获取Chrome浏览器的版本信息,用来下载对用版本的ChromeDriver1. 打开Chrome 浏览器2. 打开chrome菜单位置: help -->about Google Chrome3. 看到版本信息为: 72.0.3626.81或者直接使用命令google-chrome -version查看版本信息hxb@omg:~$ google-chrome -versionGoogle Chrome 72.0.3626.81

Ubuntu下如何安装ChromeDriver
Ubuntu下如何安装ChromeDriver

4、下载匹配Chrome version 72版本的ChromDriver1. 打开下载地址:http://chromdriver.chromium.org/2 . 选择 ChromeDriver 2.46 进行下载3. 解压缩下载的 ChromeDriver 2.46文件4. 将解压后的文件 chromeDriver复制到 /usr/bin 目录下

Ubuntu下如何安装ChromeDriver
Ubuntu下如何安装ChromeDriver
Ubuntu下如何安装ChromeDriver
Ubuntu下如何安装ChromeDriver
Ubuntu下如何安装ChromeDriver
Ubuntu下如何安装ChromeDriver

5、检验ChromeDriver 安装是否正确,在终端运行chromedriver命令hxb@omg:~/下载$ chromedriverStarting ChromeDriver 2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926) on port 9515Only local connections are allowed.Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

Ubuntu下如何安装ChromeDriver

6、在使用python使用 ChromeDriver 可能遇到的问题Can not connect to the Service /usr/bin/google-chrome-stable/usr/bin/python3.6 /home/hxb/taobaokiller/taobaokiller/TaobaoLogin.pyTraceback (most recent call last): File "/home/hxb/taobaokiller/taobaokiller/TaobaoLogin.py", line 26, in <module> driver = webdriver.Chrome(chrome_options=options,executable_path='/usr/bin/google-chrome-stable') File "/home/hxb/.local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__ self.service.start() File "/home/hxb/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 104, in start raise WebDriverException("Can not connect to the Service %s" % self.path)selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /usr/bin/google-chrome-stable

Ubuntu下如何安装ChromeDriver

7、解决Can not connect to the Service /usr/bin/google-chrome-stable问题的方法:1.在 /etc/hosts文件中配置127.0.0.1与localhost的映射: 127.0.0.1 localhost2. 删除options中可执行文件的路径,如下options = Options()driver = webdriver.Chrome(chrome_options=options)driver.implicitly_wait(2)driver.get("https://login.taobao.com/member/login.jhtml")

Ubuntu下如何安装ChromeDriver
© 手抄报圈