一、Linux机器安装google-chrome-stable

  1、设置google-chrome软件源

    sudo vim /etc/yum.repos.d/google-chrome.repo

[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=
gpgcheck=
gpgkey=https://dl.google.com/linux/linux_signing_key.pub

  2、安装依赖[过程中如提示有其他依赖缺失,可至https://rpmfind.net/linux/rpm2html/search.php 查询对应名字rpm包 执行sudo yum install -y 安装即可]

sudo yum install https://mirrors.dotsrc.org/fedora-epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm -y

sudo yum install Xvfb -y

sudo yum install xorg-x11-fonts* -y

sudo yum install https://rpmfind.net/linux/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/l/liberation-fonts-common-2.00.5-6.fc32.noarch.rpm -y

sudo yum install https://rpmfind.net/linux/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/l/liberation-mono-fonts-2.00.5-6.fc32.noarch.rpm -y

sudo yum install https://rpmfind.net/linux/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/l/liberation-sans-fonts-2.00.5-6.fc32.noarch.rpm -y

sudo yum install https://rpmfind.net/linux/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/l/liberation-serif-fonts-2.00.5-6.fc32.noarch.rpm -y

sudo yum install -y https://rpmfind.net/linux/fedora-secondary/development/rawhide/Everything/ppc64le/os/Packages/l/liberation-fonts-2.00.5-6.fc32.noarch.rpm -y

  3、安装google-chrome-stable

sudo yum install google-chrome-stable -y

二、准备客户端【webdriver随客户端发放到服务器】

  


public static WebDriver driver;
/**
* 初始化Driver
* @throws Exception
*/
public void initDriver() throws Exception {
     String path;
File file;
String osName = System.getProperty("os.name").toLowerCase();
          // webdriver 版本做持久化,driver初始化时载入内存,动态调用配置
if (getClass().getResource("/") == null) {
String chromePath = "drivers/".concat(osName.startsWith("windows") ? ContextUtils.getContextStr(CHROME_DRIVER_WINDOWS) : osName.startsWith("mac") ? ContextUtils.getContextStr(CHROME_DRIVER_MAC) : ContextUtils.getContextStr(CHROME_DRIVER_LINUX));
path = String.format("%s%starget%s%s", System.getProperty("base.dir"), File.separator, File.separator, chromePath);
file = new File(path);
} else {
String chromePath = "drivers/".concat(osName.startsWith("windows") ? ContextUtils.getContextStr(CHROME_DRIVER_WINDOWS) : osName.startsWith("mac") ? ContextUtils.getContextStr(CHROME_DRIVER_MAC) : ContextUtils.getContextStr(CHROME_DRIVER_LINUX));
path = String.format("%s%s%s", getClass().getResource("/").getPath(), File.separator, chromePath);
file = new File(path);
if (file.exists() == false) {
FileUtils.copyInputStreamToFile(new ClassPathResource(chromePath).getInputStream(), new File(path));
}
}
if (!osName.startsWith("windows")) {
try {
Runtime.getRuntime().exec(String.format("chmod 777 %s", path));
} catch (Exception ex) {
}
}
CartierSystemSettings systemSettings = systemSettingsMapper.selectValueByCode(ChromeDriverService.CHROME_DRIVER_WHITELISTED_IPS_PROPERTY);
if (null != systemSettings) {
System.setProperty(ChromeDriverService.CHROME_DRIVER_WHITELISTED_IPS_PROPERTY, systemSettings.getValue());
}
logger.info("webdriver.chrome.driver={}", path);
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, path); ChromeOptions options = getChromeOptions(osName);
driver = new ChromeDriver(options);
}
/**
* 对非mac & Windows系统开启隐藏头模式
* @param osName
* @return
*/
public static ChromeOptions getChromeOptions(String osName) {
ChromeOptions options = new ChromeOptions();
if (!osName.startsWith("mac") && !osName.startsWith("windows")) {
options.addArguments("--headless");
options.addArguments("--disable-gpu");
options.addArguments("--no-sandbox");
}
options.addArguments("--verbose");
options.addArguments("window-size=1920x1920");
return options;
}

RedHat版本Linux安装chrome-stable配合chromeDriver进行自动化测试环境准备的更多相关文章

  1. 关于Linux部分版本无法安装Chrome的问题

    在想要yum安装Chrome浏览器后发现安装没有相应的包,在查询后得知Chrome已经对Redhat和Centos等部分版本停止支持, 所以这些新版的系统中直接安装就显得有些困难了,那么从网上找到了一 ...

  2. linux安装chrome及chromedriver(转)

    1.chrome: curl https://intoli.com/install-google-chrome.sh | bash 1.1.centos安装chrome: 從 Google 下載最新版 ...

  3. 在Ubuntu上安装Chrome浏览器和ChromeDriver

    启动脚本后报错 selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have w ...

  4. linux安装chrome浏览器

    按照下面的方式安装 wget -P /home/linfu/桌面 https://dl.google.com/linux/direct/google-chrome-stable_current_amd ...

  5. Ubuntu16.4下安装Chrome浏览器以及Chromedriver

    一.Chrome浏览器的安装 对于谷歌Chrome32位版本,使用如下链接: wget https://dl.google.com/linux/direct/google-chrome-stable_ ...

  6. linux 安装 Chrome

    一.添加PPA 从Google Linux Repository(http://www.google.com/linuxrepositories/)下载安装Key,或把下面的代码复制进终端,回车,需要 ...

  7. Redhat/Centos6.x安装Chrome

    由于Chrome对rhel6.x不在支持发布版本,只能安装chromium版本! 01.下载地址 http://people.centos.org/hughesjr/chromium/6/x86_64 ...

  8. linux安装chrome

    wget http://chrome.richardlloyd.org.uk/install_chrome.sh chmod u+x install_chrome.sh ./install_chrom ...

  9. 32位linux安装chrome浏览器

    首先你需要一个安装包,可以在CSDN上搜索google-chrome-stable_current_i386.deb. 然后在终端输入 sudo apt-get install gdebi 然后找到安 ...

随机推荐

  1. JavaScript中的对象-创建对象的7种模式

    文章来源:http://blog.csdn.net/u014346301/article/details/52204967 ECMA-262把对象定义为:”无需属性的集合,其属性可以包含基本值.对象或 ...

  2. RestTemplate java.net.UnknownHostException

    背景:公司内部系统的架构升级准备用微服务一套:记录遇到的坑. 错误信息: Servlet.service() for servlet [dispatcherServlet] in context wi ...

  3. python使用SMTP发邮件时使用Cc(抄送)和Bcc(密送)

    SMTP发送邮件的时候,并没有特殊的通信语句告诉邮件服务器 谁是主送,谁是抄送/密送,这三个角色都是以同样的方式告诉邮件服务器的,然后重点在邮件内容里. 邮件内容分为头和体两部分(就像http),头部 ...

  4. dubbo-源码阅读之服务发布

    原理 dubbo根据spring 2.0的schma实现 解析xml并初始化相关bean 初始化dubbo:service为ServiceBean实例  通过spring的生命周期相应回调实现服务发布 ...

  5. AtCoder Beginner Contest 127 D,E,F

    D Integer Cards 题意:先给出n个数字,然后可以有m次操作,每次操作以数字对(x,y)表示最多能选x个数字把它变成y,问经历m次操作后n个数字和最大为多少? 解法:一个明显正确的做法是: ...

  6. 【Luogu】【关卡2-8】广度优先搜索(2017年10月)

    任务说明:广度优先搜索可以用来找有关“最短步数”的问题.恩,也可以用来“地毯式搜索”.

  7. element-ui中table渲染的快速用法

    element-ui中对table数据的渲染有一些模板式的操作,基本按照模板渲染数据即可 基本模板样式如下 <el-table :data="studentData.rows" ...

  8. Aajx调用千千音乐数据接口

    前端展示截图https://images.cnblogs.com/cnblogs_com/LiuFqiang/1429011/o_D09Q55)EL1VFEIJ(GKI%7D%7DY5.png < ...

  9. The 'with' and 'as' Keywords

    Programming is all about getting the computer to do the work. Is there a way to get Python to automa ...

  10. String的static方法

    //String concat(String str) 拼接字符串 String concat_str0 = "abc"; String concat_str1 = "b ...