之前有一篇文章介绍过在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. php文件上传错误信息

    错误信息说明 UPLOAD_ERR_OK:其值为0,没有错误发生,文件上传成功 UPLOAD_ERR_INI_SIZE:其值为1,上传的文件超过了php.ini和upload_max_filesize ...

  2. Android studio 导入工程 出现错误

    原文:http://blog.csdn.net/qazzxc111/article/details/48787419 对于刚开始使用Android studio 并且以前不了解gradle,IDE之类 ...

  3. web前端—css面试题

    1.CSS 选择符有哪些? 2.CSS 优先级的选择过程? 优先级复合就近原则,同权重的情况下有限选择最近的属性. 载入样式的话是以最后载入的定位为准. 优先级: !important > id ...

  4. 支持flv的播放神器

    h1:让浏览器支持flv去https://github.com/Bilibili/flv.js h2:让手机电脑都支持mp4使用: <link rel="stylesheet" ...

  5. org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 32; 元素类型为 "key" 的内容必须匹配 "(column)*"

    报错:部分错误信息,主要查看CauseBy Caused by: org.hibernate.InvalidMappingException: Unable to read XML at org.hi ...

  6. Java GlassPane进度条遮罩

    package com.swing.demo; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Flo ...

  7. 洛谷——P2239 螺旋矩阵

    P2239 螺旋矩阵 题目描述 一个n行n列的螺旋矩阵可由如下方法生成: 从矩阵的左上角(第1行第1列)出发,初始时向右移动:如果前方是未曾经过的格子,则继续前进,否则右转:重复上述操作直至经过矩阵中 ...

  8. Codeforces Round #294 (Div. 2) A and B and Lecture Rooms(LCA 倍增)

    A and B and Lecture Rooms time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  9. Java中的对象池技术

    java中的对象池技术,是为了方便快捷地创建某些对象而出现的,当需要一个对象时,就可以从池中取一个出来(如果池中没有则创建一个),则在需要重复重复创建相等变量时节省了很多时间.对象池其实也就是一个内存 ...

  10. qsc round#2 喵哈哈村的排队(本辣鸡想七想八的,特写此博文给自己一个提醒)

    该oj是qsc自己写的比赛,友情链接:http://qscoj.cn/ 喵哈哈村的排队 发布时间: 2017年2月26日 16:13   最后更新: 2017年2月26日 16:14   时间限制: ...