How can I run a selenium webdriver as a background process in Python?

Viewed 2281

How would this work? I got no idea I'm kinda new to selenium lol.

1 Answers

If you are using chrome driver you can do that by adding headless to the browser options like so:

from selenium import webdriver

options = webdriver.ChromeOptions()

options.add_argument('--headless')


with webdriver.Chrome(options=options) as browser:

       browser.get(url)
       # # Do other stuff

or

from selenium import webdriver

options = webdriver.ChromeOptions()

options.add_argument('--headless')

browser = webdriver.Chrome(options=options) 

browser.get(url)

# # do things

browser.close() 
Related