Headless is not working for me

97 views
Skip to first unread message

Nikita Chavan

unread,
Apr 19, 2025, 9:12:47 AMApr 19
to Selenium Users
Hi,

I am trying to make the test case headless so I used "--headless = new" chrome option as well. still After running the code chrome window is opening. Headless is not working for me.

Can someone help?

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

#headless mode
chrome_options = Options()
chrome_options.add_argument("--headless = new")
chrome_options.add_argument("--disable-gpu")
#Invoke Chrome browser
service_obj = Service(executable_path="C:/Users/nchavan/PycharmProjects/Python Testing RXO/RXO/chromedriver.exe")
driver = webdriver.Chrome(service=service_obj)

Corey Goldberg

unread,
Apr 19, 2025, 10:49:53 AMApr 19
to seleniu...@googlegroups.com

You are creating an `Options` object, but you don't use it when starting Chrome. Add `options=chrome_options` to the constructor.

Also, remove the spaces in the argument. (--headless=new)



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/ce6fa80f-5a66-4ad9-853b-9ac24bc477d3n%40googlegroups.com.

Suriya Elamparithy

unread,
Jul 26, 2025, 2:40:40 AMJul 26
to Selenium Users
"--headless = new"  ❌ (invalid argument)
  That extra space before and after = causes the Chrome driver to ignore the headless mode.

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument("--headless=new")
chrome_options.add_argument("--disable-gpu")


service_obj = Service(executable_path="C:/Users/nchavan/PycharmProjects/Python Testing RXO/RXO/chromedriver.exe")
driver = webdriver.Chrome(service=service_obj, options=chrome_options)

driver.get("https://example.com")
print(driver.title)
driver.quit()  
Reply all
Reply to author
Forward
0 new messages