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



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



  • 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()
    


Suggested Topics