安装chrome

创建yum源

  1. # cd /etc/yum.repos.d/
  2. # vim google-chrome.repo

创建yum源信息

  1. [google-chrome]
  2. name=google-chrome
  3. baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
  4. enabled=1
  5. gpgcheck=1
  6. gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

安装google-chrome

  1. # yum -y install google-chrome-stable --nogpgcheck

chrome安装路径

使用上述步骤安装完成之后,chrome的安装路径在/opt/google/chrome目录下

安装chromeDriver

查看chrome版本

  1. # google-chrome -version

下载对应版本的chromeDriver

从https://npm.taobao.org/mirrors/chromedriver/查询与chrome版本对应的chromeDriver版本,大版本对应即可,如当前chrome最新的版本是78.0.3904.97,只需要查找与78对应的chromeDriver版本即可。

找到对应的版本后,在linux上使用以下命令下载chromeDriver压缩包:

  1. # mkdir /usr/chromedriver
  2. # cd /usr/chromedriver
  3. # wget https://npm.taobao.org/mirrors/chromedriver/version/chromedriver_linux64.zip

version为chromeDriver的完整版本号

下载之后解压压缩包:

  1. # unzip chromedriver_linux64.zip

给chromeDriver文件夹赋予权限:

  1. # chmod +x /usr/chromedriver/chromedriver

安装Xvfb

安装说明

安装此软件的原因是在centos上,chromeDriver必须使用无头模式,当有不使用无头模式的需求时就需要安装此软件,否则chromeDriver无法正确启动chrome

安装Xvfb

  1. # yum install Xvfb -y
  2. # yum install xorg-x11-fonts* -y

在/usr/bin/目录下创建xvfb-chrome文件

  1. # vim /usr/bin/xvfb-chrome

在xvfb-chrome文件中输入以下内容

  1. #!/bin/bash
  2. _kill_procs() {
  3. kill -TERM $chrome
  4. wait $chrome
  5. kill -TERM $xvfb
  6. }
  7. # Setup a trap to catch SIGTERM and relay it to child processes
  8. trap _kill_procs SIGTERM
  9. XVFB_WHD=${XVFB_WHD:-1280x720x16}
  10. # Start Xvfb
  11. Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp &
  12. xvfb=$!
  13. export DISPLAY=:99
  14. chrome --no-sandbox --disable-gpu$@ &
  15. chrome=$!
  16. wait $chrome
  17. wait $xvfb

添加执行权限:

  1. # chmod +x /usr/bin/xvfb-chrome

查看当前的映射关系:

  1. # ll /usr/bin/ | grep chrom

映射关系如下所示:

  1. lrwxrwxrwx 1 root root 31 Nov 18 14:25 chrome -> /etc/alternatives/google-chrome
  2. lrwxrwxrwx 1 root root 20 Nov 18 14:25 google-chrome -> /usr/bin/xvfb-chrome
  3. lrwxrwxrwx 1 root root 32 Jun 28 18:39 google-chrome-stable -> /opt/google/chrome/google-chrome
  4. -rwxr-xr-x 1 root root 422 Nov 18 14:24 xvfb-chrome

更改chrome启动的软连接:

  1. # ln -s /etc/alternatives/google-chrome /usr/bin/chrome
  2. # rm -rf /usr/bin/google-chrome
  3. # ln -s /usr/bin/xvfb-chrome /usr/bin/google-chrome

此时再次查看映射关系,如下所示:

  1. lrwxrwxrwx 1 root root 31 Nov 18 14:36 chrome -> /etc/alternatives/google-chrome
  2. lrwxrwxrwx 1 root root 20 Nov 18 14:36 google-chrome -> /usr/bin/xvfb-chrome
  3. lrwxrwxrwx 1 root root 32 Jun 28 18:21 google-chrome-stable -> /opt/google/chrome/google-chrome
  4. -rwxr-xr-x 1 root root 422 Nov 18 14:36 xvfb-chrome

以上步骤操作完成后即可在centos环境下使用非无头浏览器,此时chromeDriver创建时不能再添加以下参数:

  1. options.addArguments("--headless")

centos7安装chrome+chromeDriver+Xvfb的更多相关文章

  1. CentOS-yum安装chrome+chromeDriver+xvfb

    安装chrome 创建yum源文件 $ vim /etc/yum.repos.d/google-chrome.repo [google-chrome] name=google-chrome baseu ...

  2. centos7安装chrome及加载poatman开发插件

    为什么要安装chrome?因为centos7的默认浏览器firefox的实在是不习惯,上面占了太多,本来显示器就不大... 好了,首先下载chome的rpm安装包(如果需要的可以留言,我有备份) 然后 ...

  3. CentOS7 安装chrome浏览器

    本篇文章主要记录如何在CentOS7.0上安装chrome. 1.配置yum下载源: 在目录 /etc/yum.repos.d/ 下新建文件 google-chrome.repo, 并且在该文件中添加 ...

  4. 【转载】CentOS7 安装Chrome浏览器

    本篇文章主要记录如何在CentOS7.0上安装Chrome浏览器. 方法1: Google官方源在国内可能无法正常访问,故而添加Fedora中文社区提供的镜像源: sudo wget http://r ...

  5. CentOS7 安装Chrome

    1. 下载Chrome浏览器的rpm包 https://www.chrome64bit.com/index.php/google-chrome-64-bit-for-linux 2. 安装Chrome ...

  6. centos7安装chrome的历程(fedora同)

    安装 首先是下载,地址奉上:http://www.google.cn/chrome/browser/desktop/index.html,选择64 bit .rpm (适用于 Fedora/openS ...

  7. Linux Centos7安装chrome浏览器

    参考:https://blog.csdn.net/u010472499/article/details/72327963 1. 配置yum源 在目录 /etc/yum.repos.d/ 下新建文件 g ...

  8. centos7安装chrome浏览器

    1.配置yum下载源: 在目录 /etc/yum.repos.d/ 下新建文件 google-chrome.repo, 并且在该文件中添加如下内容: [google-chrome]name=googl ...

  9. CentOS7安装Chrome

    1. 进入官网:https://www.google.cn/intl/zh-CN/chrome/2. 点击下载3. 直接安装:sudo yum localinstall google-chrome-s ...

随机推荐

  1. 如何对你的Linux系统进行基准测试: 3开源基准测试工具

    如何对你的Linux系统进行基准测试: 3开源基准测试工具   0 赞0 评论 文章标签:SYS  Source  benchmark  tool  开源  基准  系统     linux实用程序的 ...

  2. Ansible_创建角色_role

    一.创建角色目录结构 1.角色创建流程 1️⃣:在Ansible中创建角色不需要特别的开发工具.创建和使用角色包含三个步骤: 创建角色目录结构 定义角色内容 在playbook中使用角色 2.角色目录 ...

  3. 007.kubernets的headless service配置和ingress的简单配置

    前面配置了servcie的nodepoint和clusterIP附在均衡 一 headless service配置 1.1 默认下的DNS配置 [root@docker-server1 deploym ...

  4. C语言变量和函数命名规范

    C 语言变量和函数命名规范: 关于C语言变量和函数命名规范 据考察,没有一种命名规则可以让所有的程序员赞同,程序设计教科书一般都不指定命名规则.命名规则对软件产品而言并不是"成败悠关&quo ...

  5. strcasecmp函数和strncasecmp函数原型

    函数说明 strcasecmp()用来比较参数s1和s2字符串,比较时会自动忽略大小写的差异. 返回值    若参数s1和s2字符串相同则返回0.s1长度大于s2长度则返回大于0 的值,s1 长度若小 ...

  6. unity editor模式下读取文件夹资源

    string path = EditorUtility.OpenFolderPanel("Load png Textures", "", "" ...

  7. fragment之间相互传数据、共享数据

    在 Fragment 之间共享数据 Activity 中的两个或更多 Fragment 需要相互通信是一种很常见的现象.想象一下拆分视图 (master-detail) Fragment 的常见情况, ...

  8. GO学习-(6) Go语言基础之运算符

    Go语言基础之运算符 运算符用于在程序运行时执行数学或逻辑运算. 运算符 Go 语言内置的运算符有: 算术运算符 关系运算符 逻辑运算符 位运算符 赋值运算符 算数运算符 运算符 描述 + 相加 - ...

  9. 关于LSTM核心思想的部分理解

    具体资料可以查阅网上,这里提到一些难理解的点.别人讲过的知识点我就不重复了. LSTM 的关键就是细胞状态,按照水平线从左向右运行,如同履带,在整个链上运行. 根据时间t-1,t,t+1,我们可以看出 ...

  10. 字节首推Java成长笔记:(原理+应用+源码+调优全都有)直接复盘

    今天这篇文章我为了帮助小伙伴们快速构建Java技术栈,这份笔记包含了Java技术点的答案,面经,笔记,希望大家看完可以在短期内容快速面试复盘,达到事半功倍! 本来想将文件上传到开源网站上去,但是文件太 ...