Search code examples
pythonselenium-chromedriverheadless-browser

How to hide Chrome Driver in python?


Though I knew people asked this question but I didn't find suitable answer so I asked again. I used PhantomJS to scrape web site, but it is very slow on Mac, so I want to tru Chrome but Chrome show browser that is is bad, can I hide it? I tried code as below, that still show a small browser window..

browser = webdriver.Chrome()
browser.set_window_position(0, 0)
browser.set_window_size(0, 0)

Solution

  • REF: how-could-i-start-a-selenium-browserlike-firefox-minimized

    You can move browser window over the monitor, like this:

    driver.set_window_position(-10000,0)