how do i run selenium python with a headless browser?

Just set headless to True:

from selenium.webdriver.chrome.options import Options
options = Options()
options.headless = True 

Full code:

from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options

options = Options()
options.headless = True 

driver = webdriver.Chrome('/Users/toanhac/Downloads/chromedriver', options=options)


url = 'https://mail.google.com/mail/u/0/#inbox'
driver.get(url)

driver.implicitly_wait(15) 


driver.find_element_by_id("identifierId").send_keys(mail)
driver.find_element_by_id("identifierNext").click()

driver.find_element_by_name("password").send_keys(password)
driver.find_element_by_id("passwordNext").click()

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top