简体   繁体   中英

Blank page on headless Selenium tests run with Jenkins

Headless Selenium tests can be well run on my machine (yup, I should definitely move in this ideal place where problems doesn't exist).

However, when I launch those tests via Jenkins, none of the page elements are found. I took a screenshot to figure out why, and it shows a blank page.

This is how I instanciate my headless Chrome browser.

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--window-size=1920x1080");
chromeOptions.addArguments("start-maximised");
chromeOptions.addArguments("enable-automation");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-infobars");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--disable-browser-side-navigation");
chromeOptions.addArguments("--disable-gpu");
driver = new ChromeDriver(chromeOptions);
driver.manage().timeouts().pageLoadTimeout(30L, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(3L, TimeUnit.SECONDS);
driver.manage().window().maximize();

I have a guess but my coworker says it can't be this: should I install Xvfb on Jenkins server? I mean, is it mandatory? (I must be at least 51% sure before trying this approach ^^)

Thanks in advance.

Like Shashank Kadne mentioned, you need to set an option in Chrome to ignore certificates.

chromeOptions.addArguments("--ignore-certificate-errors");

I tried lots of solutions but it turned out that Jenkins wasn't allowed to access the resources I needed to test. So... I couldn't solve it myself anyway. Sysadmins did.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM