Running galen with headless chrome?

474 views
Skip to first unread message

fritz @ pro!vision

unread,
Jul 11, 2017, 5:09:47 AM7/11/17
to Galen Framework
Hi. I am sure you are all aware that Google has released Chrome with a headless flag. How would I go about using that with Galen? Thanks.

fritz @ pro!vision

unread,
Jul 14, 2017, 10:26:46 AM7/14/17
to Galen Framework
So I tried to run specs with

importClass(org.openqa.selenium.chrome.ChromeOptions);
importClass
(org.openqa.selenium.chrome.ChromeDriver);


function inLocalBrowser(name, size, tags, browserType) {
 
return new Device({
   
deviceName: name,
 
  tags: tags,
   size: size,
   initDriver: function (url) {
     const options = new ChromeOptions();
   options.addArguments("--headless", "--disable-gpu");
 
    const driver = new ChromeDriver(options);
     this.driver = driver;
     return this.driver;
   },
   quit: function () {
     this.driver && this.driver.quit();
   }
 });
}

but I get "a timeout waiting for xxx element". It looks like galen is not able to interact with the driver.
Any pointers? Anyone? @ivan?

tas...@drupart.net

unread,
Dec 11, 2017, 1:08:17 AM12/11/17
to Galen Framework
Did anyone managed to run tests with chrome headless?

Alan Larimer

unread,
Jan 16, 2018, 7:58:28 AM1/16/18
to Galen Framework
I would love to see a solution here for Firefox as well.  The more the merrier.

mehran....@googlemail.com

unread,
Jan 17, 2018, 9:29:29 AM1/17/18
to Galen Framework
Hi Fritz, i think you were only missing the navigation to the webpage. This is my working setup (tested with current galen and chromedriver):

initDriver: function (url) {
   
const options = new ChromeOptions();

   
// "--disable-gpu" is still needed for chrome on windows machines

    options
.addArguments("--headless", "--disable-gpu");

   
// Width and Height comma separated
    options
.addArguments('--window-size=320,640');

   
const driver = new ChromeDriver(options);

   
// navigate the given url
    driver
.navigate().to(url);

   
this.driver = driver;
   
return this.driver;
},Enter code here...



Alan Larimer

unread,
Jan 17, 2018, 12:21:46 PM1/17/18
to Galen Framework
importClass(org.openqa.selenium.firefox.FirefoxDriver);
importClass(org.openqa.selenium.firefox.FirefoxOptions);
importClass(com.galenframework.utils.GalenUtils);
importClass(com.galenframework.browser.SeleniumBrowser);

var options = new FirefoxOptions().setHeadless(true);

var browser = new SeleniumBrowser(new FirefoxDriver(options));
browser.load(args[0]);
browser.changeWindowSize(GalenUtils.readSize(args[1]));

browser;

Checking the args is the next hurdle.  I don't know how to log what is being received and
if (args[0] != undefined && args[0] != null && args[0] != '')
is not working to support both
Login page headless
    jsfactory ${driverFile} ${pageUrl} ${size}
        check ${specFile}
and
Login page headless
    jsfactory ${driverFile}
        open ${pageUrl}
        resize ${size}
        check ${specFile}

axel....@gmail.com

unread,
Jan 19, 2018, 2:02:25 PM1/19/18
to Galen Framework
Does anyone have an example for headless chrome please? I´m new to this

Axel Barfod

unread,
Jan 24, 2018, 10:29:34 AM1/24/18
to Galen Framework
I tried the following but it isn't working because for some reason it isn't navigating.

function inLocalBrowserHeadless(name, size, tags, browserType) {

return new Device({
deviceName: name,
tags: tags,
size: size,
initDriver: function (url) {
            console.log('inLocalBrowserHeadless');
console.log(url);
System.setProperty("webdriver.chrome.driver", "./test/test-e2e/bin/drivers/chromedriver");
            const options = new ChromeOptions();
            var str = size.replace("x",",");
options.addArguments("--headless",
"--remote-debugging-port=9222",
"--acceptInsecureCerts",
"--window-size="+str);
const d = new ChromeDriver(options);
d.navigate().to(url);
this.driver = d;
//this.driver.navigate().to(url);

mwalt...@gmail.com

unread,
Feb 12, 2018, 6:02:37 PM2/12/18
to Galen Framework
Are you trying to run headless chrome as root? If so try adding --no-sandbox to options.addArguements OR for the safer option, don't run as root

tas...@drupart.net

unread,
Feb 15, 2018, 7:37:03 AM2/15/18
to Galen Framework
How do you add arguments like "--headless" in .galen.config file?

Martin Reinhardt

unread,
Feb 15, 2018, 2:09:59 PM2/15/18
to Galen Framework
the next version of Galen will support this feature
Reply all
Reply to author
Forward
0 new messages