admin管理员组文章数量:1615372
linux(ubuntu)系统安装web自动化测试所需的Google Chrome浏览器和webdriver
- 前言
- 一、安装Google Chrome浏览器
- 二、安装Chromedriver
前言
在使用 Python+selenium+Chrome浏览器进行自动化测试时,需要我们的电脑上安装有 Chrome浏览器和相对应的 ChromeDriver 插件,本篇文章介绍了在linux(Ubuntu)操作系统下分别安装 Chrome 和 ChromeDriver
一、安装Google Chrome浏览器
Chrome Browser 是世界上被最广泛使用的网络浏览器。它是为现代网络构建的一款快速,易用,又安全的浏览器。
安装方法1:
1.查看linux是多少位
getconf LONG_BIT
2.下载安装包
sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google/linux/direct/google-chrome-stable_current_amd64.deb
安装方法2:
1.官网下载对应的安装包
官网链接
2.通过ftp工具上传到linux服务器
下面的步骤两种方法都一样
安装下载的包
sudo dpkg -i google-chrome*.deb
sudo apt-get install -f
检查是否安装成功
google-chrome --version
出现类似下图的版本号就表示安装成功
二、安装Chromedriver
根据浏览器的版本号选择下载chromedriver
chromedriver镜像
wget https://chromedriver.storage.googleapis/填写自己需要的版本/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
chmod +x chromedriver
查看python的安装路径并为移动后Chromedriver并创建软连接
sudo mv -f chromedriver /usr/local/share/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
通过pyton代码验证安装成果
进入python命令行
python
出现下图界面
输入下面的代码
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--window-size=1700x938')
client = webdriver.Chrome(chrome_options=chrome_options)
client.get("https://www.baidu")
print (client.title)
client.quit()
版权声明:本文标题:安装linux服务器实现自动化所需要的Google Chrome浏览器和webdriver 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1728709754a1170205.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论