简体   繁体   English

无头 Selenium 测试的空白页与 Jenkins 一起运行

[英]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).无头 Selenium 测试可以在我的机器上很好地运行(是的,我绝对应该搬到这个不存在问题的理想地方)。

However, when I launch those tests via Jenkins, none of the page elements are found.但是,当我通过 Jenkins 启动这些测试时,找不到任何页面元素。 I took a screenshot to figure out why, and it shows a blank page.我截取了一个截图来找出原因,它显示了一个空白页面。

This is how I instanciate my headless Chrome browser.这就是我实例化无头 Chrome 浏览器的方式。

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?我有一个猜测,但我的同事说不可能是这样:我应该在 Jenkins 服务器上安装 Xvfb 吗? I mean, is it mandatory?我的意思是,这是强制性的吗? (I must be at least 51% sure before trying this approach ^^) (在尝试这种方法之前,我必须至少有 51% 的把握 ^^)

Thanks in advance.提前致谢。

Like Shashank Kadne mentioned, you need to set an option in Chrome to ignore certificates.就像 Shashank Kadne 提到的那样,您需要在 Chrome 中设置一个选项来忽略证书。

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.我尝试了很多解决方案,但结果是不允许 Jenkins 访问我需要测试的资源。 So... I couldn't solve it myself anyway.所以......无论如何我自己都无法解决。 Sysadmins did.系统管理员做到了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Jenkins 运行 headless firefox Xvfb 以运行 selenium 测试 - Running headless firefox Xvfb with Jenkins to run selenium tests Jenkins 在后台运行 Selenium 测试 - Jenkins run Selenium tests on background 在詹金斯中,“运行硒测试处于无头模式”是什么意思 - What does mean by “running selenium tests are in headless mode ” in jenkins 在无头Chrome中针对Angular应用程序运行Selenium测试 - Run Selenium tests against an Angular application in headless Chrome 无法在非无头模式ChromeDriver和Chrome上运行Selenium测试 - Unable to run Selenium tests on non-headless mode ChromeDriver and Chrome 通过Jenkins / Hudson运行本地硒测试 - Run local Selenium Tests via Jenkins/Hudson 硒测试在本地计算机上运行,​​但不通过詹金斯运行 - Selenium tests run on local machine but not through jenkins 无法在 Jenkins 中正确运行硒测试 - Unable to run selenium tests correctly in Jenkins 詹金斯(Jenkins)不运行我的Selenium测试(“无测试可运行”) - Jenkins doesn't run my Selenium tests ('No tests to run') 无法使用Selenium Web驱动程序在VS 2010上的Chrome / Firefox / IE上运行自动化测试-显示空白页? - Unable to run automated tests in VS 2010 on Chrome/Firefox/IE using Selenium Web driver - Shows blank page ??
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM