RedHat版本Linux安装chrome-stable配合chromeDriver进行自动化测试环境准备
一、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进行自动化测试环境准备的更多相关文章
- 关于Linux部分版本无法安装Chrome的问题
在想要yum安装Chrome浏览器后发现安装没有相应的包,在查询后得知Chrome已经对Redhat和Centos等部分版本停止支持, 所以这些新版的系统中直接安装就显得有些困难了,那么从网上找到了一 ...
- linux安装chrome及chromedriver(转)
1.chrome: curl https://intoli.com/install-google-chrome.sh | bash 1.1.centos安装chrome: 從 Google 下載最新版 ...
- 在Ubuntu上安装Chrome浏览器和ChromeDriver
启动脚本后报错 selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have w ...
- linux安装chrome浏览器
按照下面的方式安装 wget -P /home/linfu/桌面 https://dl.google.com/linux/direct/google-chrome-stable_current_amd ...
- Ubuntu16.4下安装Chrome浏览器以及Chromedriver
一.Chrome浏览器的安装 对于谷歌Chrome32位版本,使用如下链接: wget https://dl.google.com/linux/direct/google-chrome-stable_ ...
- linux 安装 Chrome
一.添加PPA 从Google Linux Repository(http://www.google.com/linuxrepositories/)下载安装Key,或把下面的代码复制进终端,回车,需要 ...
- Redhat/Centos6.x安装Chrome
由于Chrome对rhel6.x不在支持发布版本,只能安装chromium版本! 01.下载地址 http://people.centos.org/hughesjr/chromium/6/x86_64 ...
- linux安装chrome
wget http://chrome.richardlloyd.org.uk/install_chrome.sh chmod u+x install_chrome.sh ./install_chrom ...
- 32位linux安装chrome浏览器
首先你需要一个安装包,可以在CSDN上搜索google-chrome-stable_current_i386.deb. 然后在终端输入 sudo apt-get install gdebi 然后找到安 ...
随机推荐
- DDCTF 北京地铁
这周打了ddctf,被打成了dd 北京地铁题目给了一张北京地铁图,提示如下:Color Threshold 提示:AES ECB密钥为小写字母提示2:密钥不足位用\0补全提示3:不要光记得隐写不看图片 ...
- 三、hibernate中持久化类的使用
hibernate的持久化类 持久化:将内存中的一个对象持久化到数据库中的过程,hibernate就是一个用来进行持久化的框架 持久化类:一个Java对象与数据库中表建立了关系映射,那么这个类在hib ...
- MyBatis笔记一:GettingStart
MyBatis笔记一:GettingStart 1.MyBatis优点 我们的工具和各种框架的作用就是为了我们操作数据库简洁,对于一些数据库的工具能帮我们少写一些处理异常等等的代码,但是他们并不是自动 ...
- subst - 替换文件中的定义
总览 (SYNOPSIS) subst [ -e editor ] -f substitutions victim ... 描述 (DESCRIPTION) Subst 能够 替换 文件 的 内容, ...
- frp使用(windows+aliyun-windows)
下载frp:https://github.com/fatedier/frp/releases/ 解压,修改服务端配置文件:frps.ini:如下: [common] # 设置连接端口 bind_por ...
- Ansible 和 Playbook 暂存
Ansible 和 Playbook 暂存 , 也是一个批量管理工具 自动化的批量管理工具 主机清单 HOST Inventory 模块插件 Playbooks 查看ansible的目录结构 ...
- Hbase速览
一.概述 理解为hadoop中的key-value存储,数据按列存储,基于HDFS和Zookeeper 1.应用 2.场景 适用场景: 存储格式:半结构化数据,结构化数据存储,Key-Value存储 ...
- cmake README.TXT
{ cmake .//在当前路径下构建项目 cmake --build .//在当前路径下生成项目(默认为debug)//cmake --build . --config release//在当前路径 ...
- MySql5.7默认生成的密码无法正常登陆
1.修改 /etc/my.cnf,在 [mysqld] 小节下添加一行:skip-grant-tables=1 这一行配置让 mysqld 启动时不对密码进行验证 2.重启 mysqld 服务:sys ...
- spring之循环依赖问题如何解决
首先,spring是支持循环依赖的.但是循环依赖并不好. 最近,我在使用jenkins自动化部署,测试打出来的jar包,出现了循环依赖的问题. 在这里说一下,我解决问题的过程 我首先根据提示找到循环依 ...