2

While running the test in selenium Webdriver using JAVA, I do not want the webpage to be seen on the screen. Is there a way that the program runs and the webpage is not seen.

1
  • You could try using PhantomJS driver. Commented Apr 1, 2016 at 4:33

2 Answers 2

2

If you don't have the budget for a dedicated machine to run tests, then a simple trick is to launch the browser off-screen:

ChromeOptions options = new ChromeOptions();
options.addArguments("--window-position=-32000,-32000");

WebDriver driver = new ChromeDriver(options);
driver.get("http://stackoverflow.com");
Sign up to request clarification or add additional context in comments.

Comments

0

Yes you can do this like below Use HtmlUnitDriver it opens your web page in headless mode i.e no visibility of any web page for more info about html unit driver please visit

https://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.html

also visit http://stackoverflow.com/questions/12807689/selenium-vs-htmlunit

Now back to question

WebDriver driver = new HtmlUnitDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// do some action with html unit driver
// for example open google home page
driver.get("http://www.google.com");
// now verify that google home page is loaded properly
System.out.println("Printing Title of the Google Home Page : " + driver.getTitle());

// above line prints on console : Printing Title of the Google Home Page : Google

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.