Saturday, 11 February 2023

DeprecationWarning: headless property is deprecated, instead use add_argument('--headless') or add_argument('--headless=new') on Selenium 4.8.0 Python

I am trying to execute a basic program using Selenium 4.8.0 Python clients in headless mode:

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

options = Options()
options.headless = True
s = Service('C:\\BrowserDrivers\\chromedriver.exe')
driver = webdriver.Chrome(service=s, options=options)
driver.get('https://www.google.com/')
driver.quit()

With the following configuration:

  • Selenium 4.8.0 Python
  • Chrome _Version 109.0.5414.120 (Official Build) (64-bit)
  • ChromeDriver 109.0.5414.25

Though the program gets executed successfully there seems to a DeprecationWarning as:

DeprecationWarning: headless property is deprecated, instead use add_argument('--headless') or add_argument('--headless=new')

Can anyone explain the DeprecationWarning and the required changes?



from DeprecationWarning: headless property is deprecated, instead use add_argument('--headless') or add_argument('--headless=new') on Selenium 4.8.0 Python

No comments:

Post a Comment