1

i've been trying for hours launching a selenium web browser and now it's done, i can't put it in headless mode ( want it to perform tasks in background ). My electron app is a simple quick start with a button launching a Selenium webdriver. Here's my code :

document.getElementById("test").onclick = function () {
  require('chromedriver');
  var webdriver = require('selenium-webdriver');
    var chromeCapabilities = webdriver.Capabilities.chrome();
    //setting chrome options
    var chromeOptions = {
        'args': ['--headless']
    };
    chromeCapabilities.set('chromeOptions', chromeOptions);
    var driver = new webdriver.Builder().withCapabilities(chromeCapabilities).build();
    driver.get('http://www.google.com/');
 };

What it makes : When you press the test button, selenium browser is launched and appears in my screen instead of being headless or in background :( It seems like it doens't take in consideration the args of the chromeOption variable. I tried to put many different flags with many different syntaxes but noone of them worked. Does anyone have a solution please ?

KataClysm
  • 11
  • 2
  • check out: https://stackoverflow.com/questions/44197253/headless-automation-with-nodejs-selenium-webdriver – Alex L Feb 22 '20 at 18:39
  • My guess would be that you need to do that code in your main process; but I'm surprised it works at all in the renderer process, and no time to do a test now... which is why this is a comment, not an answer :-) – Darren Cook Feb 23 '20 at 08:12

0 Answers0