Selenium is one of the powerful package available in Python , used for web automation , no doubt about that. In the last we learned how to use a web driver with webdriver manager package. In this we will learn how to use a headless mode of action in selenium webdriver.
What is headless mode ? In head less mode ,browser you automate work in the background and the work can be completed silently. So how to run selenium web driver in headless mode .
- You need to create browser option and add –headless.
- Add the option to webdriver
Create a chrome option as follows and add attch to the web driver.
from selenium.webdriver.chrome.options import Options chrome_opt = Options() chrome_opt.add_argument('--headless') browser = webdriver.Chrome(executable_path=ChromeDriverManager().install(),chrome_options=chrome_opt)
That’s all you need to know