Selenium Headless in ChromeDriver Fails

78 Views Asked by At

I am running the following Python code:

from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions as EC

service = Service(executable_path=r"\chromedriver.exe")
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
driver = webdriver.Chrome(service=service, options=options)

But the headless option does not work and I get the Chrome Driver window opening. What might be the problem? Thank you!

1

There are 1 best solutions below

0
thetaco On

I used options.add_argument("--headless") instead of "--headless=new" and it worked just fine.