9

I want to run the scripts in Headless mode for all the 3 browsers Chrome, Firefox & IE

The following is the code for Chrome:

   System.setProperty("webdriver.chrome.driver", "./drive/chromedriver.exe");

    ChromeOptions options = new ChromeOptions();

    options.addArguments("headless");

    options.addArguments("window-size=1400,600");

    WebDriver driver = new ChromeDriver(options);

    driver.get("http://www.google.com/");

Note : Its working fine

Firefox:

    FirefoxBinary firefoxBinary = new FirefoxBinary();

    firefoxBinary.addCommandLineOptions("--headless");

    System.setProperty("webdriver.gecko.driver", "./drive/geckodriver.exe");

    FirefoxOptions firefoxOptions = new FirefoxOptions();

    firefoxOptions.setBinary(firefoxBinary);

    FirefoxDriver driver = new FirefoxDriver(firefoxOptions);

     driver.get("http://www.google.com/");

Note : Its working fine

IE:

Similarly i want to execute in IE with options

1 Answer 1

7

IE does not have support for a headless mode (since IE nowadays does not recieve any kind of update or improvements.).

But you can use trifle.js, a kind of browser that can emulate some IE versions in a headless mode, since its coded as a port of PhantomJS.

3
  • I couldn't find any example about trifle.js. How can I add trifle.js to my c# code Sep 26, 2021 at 9:48
  • @UglukFromIsengard triffle runs using phantonJs api. So you need to download its .exe file and load and use it as a phantonJs driver, and about that you will find a tons of examples in web. Sep 27, 2021 at 18:11
  • I downloaded TripleJS, its just a .exe file. And I tried to give as phantonJs Driver in C# code. It doesn't accept it. It still looking for phantomJs.exe when I run my code. I couldn't figure out how I can use TripleJS as phantonJs driver. Can you share an example with me? Btw, I am trying to implement tripleJS as a selenium webdriver in C#. Sep 28, 2021 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.