Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
128 views
in Technique[技术] by (71.8m points)

How can I run robot headlessly from jenkins for selenium?

I'm working a maven project doing browser testing with selenium and chromedriver. One of our user login features uses a PKI cert so to select a cert we use robot to interact with the 'Select a certificate' popup. When running maven test from jenkins, I get the error java.awt.AWTException: headless environment at java.awt.Robot.<init>(Robot.java:91). Looking into solutions I found that xvfb can be used to run robot headlessly so I have xvfb running on the jenkins node and the display port set to 99, however this doesn't solve the issue. I'm wondering if there are any configurations I need to make with the chromedriver or xvfb to get it to work. Chrome options are:

        try {
            System.setProperty("webdriver.chrome.driver", "<path to chrome driver>");
            ChromeOptions options = new ChromeOptions();
            options.addArguments("--window-size=1920,1080");
            options.addArguments("--headless");
            options.addArguments("--ignore-certificate-errors");
            driver = new ChromeDriver(options);
            
            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

As a side note, all other tests that don't use PKI pass.

question from:https://stackoverflow.com/questions/65908375/how-can-i-run-robot-headlessly-from-jenkins-for-selenium

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...