江梆梆我爱编程

Jenkins执行selenium不能启动浏览器的解决方法

2018-04-06  本文已影响710人  云谁之殇

关于在Linux下,使用Jenkins执行selenium执行自动化测试任务时不能启动浏览器的解决方法:

sudo apt-get install vnc4server
# Now start the VNC server once as the jenkins user and give it a password, 
# otherwise it'll try to ask Jenkins
su jenkins
[enter password: vncserver]

then kill that VNC session (for example "vncserver -kill :1")
1.png
driver.manage().window().maximize();

修改为在启动浏览器时添加最大化参数:

public static WebDriver getChromeDriver() {
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--start-maximized","--test-type");
        return new ChromeDriver(options);
    }
上一篇 下一篇

猜你喜欢

热点阅读