ubuntu 16.04安装selenium

2019年3月16日 0 条评论 2.34k 次阅读 0 人点赞

环境:ubuntu版本号:16.04 Python版本号:3.7

安装步骤:
1、安装selenium;

$  sudo pip install selenium

备注:pip如果存在多个版本,需要标明版本号,例:pip3.7

2、查看selenium版本号:

>>>import selenium
>>>print(selenium.__version__)

3.9.0

3、测试:

from selenium import webdriver
webdriver.Chrome().get('http://www.baidu.com')

chrome浏览器打开,停留在百度主页;

注意事项:
1.第一次测试时出现如下错误提示:
selenium.common.exceptions.WebDriverException: Message: unknown error: Devtools port number file contents <35024> were in an unexpected format
  (Driver info: chromedriver=72.0.3626.121,platform=Linux 4.4.0-21-generic x86)
解决方案:
chrome浏览器版本过低,48....,升级后重新安装即可;

升级方案:
(1)可直接使用Ubuntu kylin中心;
(2)命令行升级方案:

$ sudo apt-get update
$ sudo apt-get install -y google-chrome-stable

当当当当!selenium安装完成,可以愉快的玩耍啦~~~~




fan

这个人太懒什么东西都没留下

文章评论(0)

你必须 登录 才能发表评论