环境: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安装完成,可以愉快的玩耍啦~~~~
© 著作权归作者所有
文章评论(0)