1

我正在尝试使用 selenium docker chrome 节点在 docker 上运行 selenium 测试。我们在 Windows 7 上运行它。由于 docker 不支持 Windows 7,我们使用 vagrant 创建 linux box,然后在 linux box 上使用 docker 运行 selenium hub 和 selenium node/chrome。

当我尝试使用以下代码运行 selenium 脚本时,出现“无法访问此站点”错误。但是 chrome 会话成功创建并且驱动程序启动了网站。但是该站点显示错误为“无法访问此站点”

ChromeOptions options = new ChromeOptions();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);
driver.get("http://www.google.com");

我的公司正在使用代理服务器。我还在 vagrant vm box 和 docker 容器中设置了代理设置。因此,当我在 linux box 和 docker selenium 容器上使用“curl www.google.com”时,我成功地得到了响应。

当我可以在容器和 linux 机器上成功启动网站时,我不确定为什么通过 selenium WebDriver 启动网站时没有呈现网站。

我尝试使用如下代理设置启动 WebDriver,但出现相同的错误

Proxy proxy = new Proxy();
proxy.setProxyType(Proxy.ProxyType.MANUAL)
proxy.setHttpProxy("<username>:<password>:<proxy_url>)
ChromeOptions options = new ChromeOptions();
options.setCapability("proxy", proxy);
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);
driver.get("http://www.google.com");
4

0 回答 0