加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

selenium-webdriver – Webdriver异常:“chrome无法访问”

发布时间:2020-12-16 03:37:20 所属栏目:安全 来源:网络整理
导读:我在ubuntu服务器上运行selenium测试用例,它基本上运行firefox和chrome中的测试用例. Firefox启动和测试用例成功运行但chrome抛出异常: *****下面是stacktrace的片段:***** 在端口21549上启动ChromeDriver(v2.8.240825) PAC支持已禁用,因为没有系统实现 Te

我在ubuntu服务器上运行selenium测试用例,它基本上运行firefox和chrome中的测试用例.
Firefox启动和测试用例成功运行但chrome抛出异常:

*****下面是stacktrace的片段:*****

在端口21549上启动ChromeDriver(v2.8.240825)

PAC支持已禁用,因为没有系统实现

Test IntegrationTest.AdminUserelementscheck失败:

org.openqa.selenium.WebDriverException:chrome无法访问
?(驱动程序信息:chromedriver = 2.8.240825,platform = Linux 2.6.32-431.el6.x86_64 x86_64)(警告:服务器未提供任何堆栈跟踪信息)
[错误]命令持续时间或超时:20.83秒

嗨下面是我的代码的小片段:

public class IntegrationTest {

private static final String configFile="test.properties";

private final String FIREFOX="firefox";

private final String CHROME="chrome";

private final String PHANTOMJS="phantomjs";

private final String BROWSERNAME="browser";

private static Properties props = new Properties();

public WebDriver webDriver;

private static Configuration additionalConfigurations;


@BeforeClass

public static void setUp() throws IOException,SQLException{

props.load(IntegrationTest.class.getResourceAsStream("/" + configFile));
        }

@test

public void AdminUserelementscheck() throws SQLException,IOException {

String[] browsers = props.getProperty(BROWSERNAME).split(",");

System.out.println("Number of browsers specified in conf:"+props.getProperty(BROWSERNAME));

for(String browser:browsers){

System.out.println("Browser currently processing:"+browser);

if(browser.equalsIgnoreCase(FIREFOX))

webDriver = new FirefoxDriver();

else if(browser.equalsIgnoreCase(CHROME))

webDriver = new ChromeDriver();

else

webDriver = new PhantomJSDriver();

running(testServer(3333,fakeApplication()),webDriver,new Callback
最佳答案
这是因为Chrome也在使用unix容器来运行.如果要在docker中运行它,请传递docker run命令

–privileged

否则,您可以启动Chrome

–no-sandbox

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读