-4

How can I use Headless Browser with Selenium and C#.Net.

I am new in selenium so can any help me.

Sumit Garg
  • 29
  • 8
  • 1
    Do you have s *spcecific* problem on using it? Have you even tried anything that doesn´t work? How to use is a quite bad and broad question. Please have a look at https://stackoverflow.com/help/how-to-ask – MakePeaceGreatAgain May 04 '18 at 06:14

1 Answers1

0

While there are several such headless browsers available in the market, the following are the most popular ones:

  • Headless Chrome
  • PhantomJS
  • SlimerJS
  • TrifleJS
  • HTMLUnit driver

Pseudo code:

  package chrome;
           public class HeadlessTesting {
                public static void main(String[] args) throws IOException{
                    System.setProperty("webdriver.chrome.driver",
                            "ChromeDriverPath");
                    ChromeOptions options = new ChromeOptions();
                    options.addArguments("headless");
                    options.addArguments("window-size=1200x600");
                    WebDriver driver = new ChromeDriver(options);
                    driver.get("https://contentstack.built.io");
                    driver.get("https://www.google.co.in/");
                    System.out.println("title is: " + driver.getTitle());
                    File scrFile = ((TakesScreenshot) driver)
                            .getScreenshotAs(OutputType.FILE);
                    FileUtils.copyFile(scrFile, new File("pathTOSaveFile"));
                    driver.quit();
                }
            }
bommelding
  • 2,969
  • 9
  • 14
  • 1
    While the question itself it pretty unclear and broad, it´s rarely a good idea to answer it as you risk downvotes. In particular you may post a solution the OP already tried, so whom would you help then? – MakePeaceGreatAgain May 04 '18 at 06:19
  • @HimBromBeere This pseudo code is for example. Maybe Mss tester, will get some part of the code, and will find the solution? Who knows? – Zhivko.Kostadinov May 04 '18 at 08:03