- 安装docker yum -y install docker
- https://cr.console.aliyun.com/cn-qingdao/instances/mirrors 镜像加速器 获取镜像文件
- 在/etc/docker/daemon.json 文件中添加 “registry-mirrors”: [“https://xqyh0p5t.mirror.aliyuncs.com”]
- systemctl daemon-reload 重新加载文件
- systemctl restart docker重启
- 查看是否启动systemctl status docker
- docker pull selenium/hub 下载selenium容器
- docker pull selenium/node-chrome-debug Chrome容器
- docker images 查看有哪些容器
- docker ps 查看当前进程
- docker run -d -p 5555:4444 selenium/hub 启动seleniumhub 即selenium gride,虚拟机5555端口和容器4444端口映射
- 关联Chrome对应镜像服务 和selenium 容器 docker run -P -d --link 97865b2932cc:hub selenium/node-chrome-debug

- http://192.168.1.11:5555/grid/console 网页查看是否启动

- 代码层调用
Public class GridTest {
@Test
public void test() throws Exception {
ChromeOptions options=new ChromeOptions();
//url为IP+虚拟机端口
WebDriver driver=new RemoteWebDriver(new URL("http://192.168.1.11:5555/wd/hub"),options);
driver.get("http://www.baidu.com");
File file=((TakesScreenshot)driver).getScreenshotAs(org.openqa.selenium.OutputType.FILE);
Files.copy(file, new File("report/gride.png"));
}
}