当前位置: 代码迷 >> 综合 >> Selenium Gride 分布式运行 docker简要配置
  详细解决方案

Selenium Gride 分布式运行 docker简要配置

热度:52   发布时间:2024-01-30 14:37:03.0
  1. 安装docker yum -y install docker
  2. https://cr.console.aliyun.com/cn-qingdao/instances/mirrors 镜像加速器 获取镜像文件
  3. 在/etc/docker/daemon.json 文件中添加 “registry-mirrors”: [“https://xqyh0p5t.mirror.aliyuncs.com”]
  4. systemctl daemon-reload 重新加载文件
  5. systemctl restart docker重启
  6. 查看是否启动systemctl status docker
  7. docker pull selenium/hub 下载selenium容器
  8. docker pull selenium/node-chrome-debug Chrome容器
  9. docker images 查看有哪些容器
  10. docker ps 查看当前进程
  11. docker run -d -p 5555:4444 selenium/hub 启动seleniumhub 即selenium gride,虚拟机5555端口和容器4444端口映射
  12. 关联Chrome对应镜像服务 和selenium 容器 docker run -P -d --link 97865b2932cc:hub selenium/node-chrome-debug
    在这里插入图片描述
  13. http://192.168.1.11:5555/grid/console 网页查看是否启动
    在这里插入图片描述
  14. 代码层调用
Public class GridTest {@Testpublic 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"));}
}
  相关解决方案