之前有一篇文章介绍过在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. node自动调试

    supervisor 第一步:安装:npm -g install supervisor没有权限的时候可以sudo npm -g install supervisor 第二步:使用:supervisor ...

  2. beego学习笔记(1)

    公司准备开发一个针对塔吊行业的APP. 后台采用微服务,docker容器部署. 准备采用go进行微服务的开发. 采用beego进行restful API的开发. 第一步,访问beego的官方网站: h ...

  3. LeetCode解题报告—— Swap Nodes in Pairs & Divide Two Integers & Next Permutation

    1. Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. For e ...

  4. Permutations I&&II

    Permutations I Given a collection of distinct numbers, return all possible permutations. For example ...

  5. Linux 基础——开山篇

    为什么要开始学习Linux命令? 首先当然是因为工作需要了,现在的工作是负责银行调度的系统的源系统接入的工作,经常要到生产部署版本.所以……买了一本<Linux命令行与shell脚本编程大全&g ...

  6. 智能社官网顶部导航实现demo

    从智能社的blue老师公开课中学习到了很多,在此表示感谢. 这个导航很好玩,于是就想实现一个. html <div id="box"> <ul> <l ...

  7. 六十五 async/await

    用asyncio提供的@asyncio.coroutine可以把一个generator标记为coroutine类型,然后在coroutine内部用yield from调用另一个coroutine实现异 ...

  8. 插入排序(InsertionSort)

    算法描述 插入排序是在一个已经有序的数据序列,要求在这个已经排好的数据序列中插入一个数,但要求插入后此数据序列仍然有序.插入排序是一种稳定的排序. 基本思想 插入排序是在一个已经有序的小序列的基础上, ...

  9. thinkphp的where方法的使用

    1.Thinkphp中where()条件的使用 总是有人觉得,thinkphp的where()就是写我要进行增加.查询.修改.删除数据的条件,很简单的,其实我想告诉你,where()是写条件语句的,但 ...

  10. Xamarin XAML语言教程模板页面TemplatedPage

    Xamarin XAML语言教程模板页面TemplatedPage 模板页面TemplatedPage 在上文中我们提到了TemplatedPage,它被称为模板页面,用来显示控件模版.Templat ...