之前有一篇文章介绍过在ubuntu下安装selenium和firefox

现在介绍下centos7

注意以下都是下载的linux64位的软件,32位的请自己找下链接,

现在使用的python的版本是3,请注意,2应该也可以运行

需要的版本有

firefox 57.0.4

cd /usr/local/firefox

wget https://download-ssl.firefox.com.cn/releases/firefox/57.0/zh-CN/Firefox-latest-x86_64.tar.bz2

tar -xjf Firefox-latest-x86_64.tar.bz2

接着建立软链接

ln -s /usr/local/firefox/firefox/firefox /usr/bin/firefox

这样firefox就下载完成

根据需要去官网下载

selenium 3.8.1

pip install selenium

geckodriver 0.19.1

wget https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz

tar -zxvf tar -zxvf geckodriver-v0.19.1-linux64.tar.gz

ln -s /xxx当前的路径/geckodriver /usr/bin/geckodriver

根据需要去官网下载

到这里基本完成了,可以在本地环境运行selenium

给个demo

#!/usr/bin/python3

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('https://www.baidu.com')
print(driver.title)
driver.quit()

以上firefox默认路径都是/usr/bin/firefox

如果要在Xshell上运行,还需要安装一些额外的东西

pyvirtualdisplay

pip install pyvirtualdisplay

以及xvfb

wget http://vault.centos.org/6.5/os/x86_64/Packages/xorg-x11-server-Xvfb-1.13.0-23.el6.centos.x86_64.rpm

yum localinstall xorg-x11-server-Xvfb-1.13.0-23.el6.centos.x86_64.rpm

到这里就结束了

最后给个demo

#!/usr/bin/python3

from selenium import webdriver
from pyvirtualdisplay import Display display = Display(visible=0, size=(800,600))
display.start()
driver = webdriver.Firefox()
driver.get('https://www.baidu.com')
print(driver.title)
driver.quit()
display.stop()

以上firefox默认路径都是/usr/bin/firefox

centos7 安装selenium和firefox的更多相关文章

  1. Ubuntu16.04/centos7 下为chrome/firefox安装flash player插件

    为chrome安装flash: 打开终端,输入:sudo apt-get install pepperflashplugin-nonfree 或官网下载安装google-chrome-stable 为 ...

  2. windows下安装配置python + selenium 来驱动firefox

    第一步,首先下载安装python ,我下载的是3.5版本,这个版本,自带了pip工具,不需要安装pip了 :) 链接地址:python 3.5 第二步,执行pip install selenium 安 ...

  3. Centos 7.6 安装selenium+firefox+google chrome(支持xshell运行)

    1. 查看Linux 版本 [root@penguin selenium]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) ...

  4. selenium启动firefox时加载扩展

    有些时候,我们测试需要用到插件或者已经导入的证书(比如金融和安全加密行业),而selenium启动firefox时会打开一个新的,不含有任何插件和个人证书的firefox(等同于全新安装后第一次打开的 ...

  5. 【Selenium】2.安装Selenium IDE和 FireBug

    本文供学习交流之用,没有商业用途,没有盈利. 完全是我自己为督促自己学习而翻译的.翻译的不好,见谅.来源于:http://www.guru99.com/install-selenuim-ide.htm ...

  6. selenium和Firefox版本不兼容

    selenium8.py coding = utf-8 from selenium import webdriver driver = webdriver.Firefox() driver.get(' ...

  7. ubuntu16.04 python3 安装selenium及环境配置

    环境 ubuntu16.04 python3 安装selenium sudo pip3 install seleium 默认安装完是支持firefox,但是更新得太慢对于较新的firefox已经不支持 ...

  8. python中用selenium调Firefox报错问题

    python在用selenium调Firefox时报错: Traceback (most recent call last):  File "G:\python_work\chapter11 ...

  9. selenium启动Firefox失败

    今天搭建java+selenium环境,搭建几次都失败,总结一下原因 1. selenium启动Firefox,不需要额外的driver 2. Friefox如果没有安装到默认路径C盘,代码中需要修改 ...

随机推荐

  1. 安装vmware+CentOS 7.4

    安装步骤 选择第一个 按tab键 空格下一行 输入 红框内容  回车 注意事项 道路不通排查过程1.ip地址2.vmware 编辑-虚拟网络编辑器3.windows 服务 vmware相关服务 要开启 ...

  2. 利用ncurses库开发终端工具箱(1)—— ToDoList小工具开发

    准备工作 腾讯云服务器(Ubuntu),C++编程语言 由于想输出界面中包含中文,所以安装库 libncursesw5,依次输入下面三行命令 sudo apt-get install libncurs ...

  3. LoadRunner中常用函数参考手册

    基础篇1:LoadRunner中常用函数参考手册 常用函数列表 web_url web_submmit_form VS web_submmit_data VS web_custom_request w ...

  4. bzoj1597 斜率优化dp

    思路:先把没有用的土地去掉,然后按照x轴排序,容易得到dp转移方程 dp[ i ] = min{ dp[ j ] + b[ j + 1 ] * a[ i ] }    0 <= j < i ...

  5. 日志 log4net

    先引入log4net 接着配置configuration文件 <?xml version="1.0"?><configuration> <system ...

  6. ajaxReturn 之前dump调试,导致$.ajax不能正常运行

    ajaxReturn 之前dump调试,导致$.ajax不能正常运行 以后调试的时候,注意下这个情况

  7. Loj#6432「PKUSC2018」真实排名(二分查找+组合数)

    题面 Loj 题解 普通的暴力是直接枚举改或者不改,最后在判断最后对哪些点有贡献. 而这种方法是很难优化的.所以考虑在排序之后线性处理.首先先假设没有重复的元素 struct Node { int p ...

  8. 洛谷——P2908 [USACO08OPEN]文字的力量Word Power

    P2908 [USACO08OPEN]文字的力量Word Power 题目描述 Farmer John wants to evaluate the quality of the names of hi ...

  9. 35、Flask实战第35天:权限设计

    二进制及其相关运算 认识二进制 0,1,2,3,4,5,6,7,8,9,10:逢10进1 0,1:逢2进1 二进制转十进制 十进制 二进制 0 0 1 1 2 10 3 11 4 100 255 11 ...

  10. 对Webservice的理解

    eb   Service使用的是   SOAP   (Simple   Object   Access   Protocol)协议 soap协议只是用来封装消息用的.封装后的消息你可以通过各种已有的协 ...