之前有一篇文章介绍过在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. linux命令(1):sed命令

    实例一: Config_file文件内容如下: sed去除注释行:sed -i -c -e '/^#/d' config_file  [会删除指定文件带有注释行] sed去除空行: sed -i -c ...

  2. Idea创建模板

    新建文件模板 /** * * @author zenglw * @date ${DATE} */ Mapper #if (${PACKAGE_NAME} && ${PACKAGE_NA ...

  3. mysql中json数据的拼接方式

    SELECT CONCAT('[', GROUP_CONCAT( CONCAT('{"id":"',STRUCTURE_ID,'"'),',', CONCAT( ...

  4. nginx 开启 gzip

    gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_comp_level 2; gzip_types text/plain applicatio ...

  5. LoadRunner读取文件并验证

            checkprocess()  {  char command[1024];  int i, total = 0;  char buffer[12], ch;  char *filen ...

  6. catalina.out日志切割

    安装cronlog rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum ins ...

  7. [TCO2013]LitPanels

    题意:一个$n\times m$的无色网格,你可以在其中选择两个$x\times y$的子矩形并在其中将其中任意的格子涂上颜色,问最终能得到多少种不同的网格 做这题会用到一个概念叫包围盒(boundi ...

  8. 解决maven无法下载jar的问题

    先去本地仓库查看是否有没有jar包,如果没有并且存在除jar包以外的文件,先将文件删除,重新用maven下载一遍.如果还是不行,就自己下载jar包导入到本地仓库,但是不能手动的添加文件夹和pom.xm ...

  9. mybatis批量插入:oracle和mysql的区别

    一.oracle批量插入 <insert id="save" parameterType="java.util.List"> insert into ...

  10. Educational Codeforces Round 8 C. Bear and String Distance 贪心

    C. Bear and String Distance 题目连接: http://www.codeforces.com/contest/628/problem/C Description Limak ...