2

I have tried

options.add_argument("--headless")

driver = new ChromeDriver(options)

it's working fine but my requirement is to hide it after initialization.

Ravi vanzara
  • 73
  • 1
  • 7
  • What do you mean *hide it after initialization*? how what you want is different from using headless? – Guy Jan 01 '20 at 10:02

2 Answers2

1

As you can see here: How to execute tests with selenium webdriver while browser is minimized there is no way for the browser to be minified.

You could in theory move the browser out of view as described here https://sqa.stackexchange.com/questions/15484/how-to-minimize-the-browser-window-which-was-launched-via-selenium-webdriver

driver.manage().window().setPosition(new Point(-2000, 0))

Chrome headless is an instance of chrome. You can't start from normal mode and switch to headless mid test. Once you start testing with any kind of browser mode, you need to stick to it. There are some work arounds I've not tried with opening windows with code and continuing from the new window.

Athanasios Kataras
  • 25,191
  • 4
  • 32
  • 61
-1

Use phantomJSDriver for Headless automation

WebDriver driver = new PhantomJSDriver();

Jagan T
  • 30
  • 1
  • 5
  • PhantomJS was deprecated almost three years ago in favor of headless chrome. And this is not what the OP asked anyway. – Guy Jan 01 '20 at 11:12