Handling headless mode in different browsers using Selenium Python client
As per the Change Log of Selenium Python client v3.12.0:
- Deprecate Options
set_headless
methods in favor of property setter
Hence, if you are using Selenium WebDriver v 3.12.0 or above, instead of chrome_options.add_argument("--headless")
you need to use the headless
property setter as follows:
options.headless = True
Else you may see a DeprecationWarning
as follows:
DeprecationWarning: use setter for headless property instead of set_headless opts.set_headless(headless=True)
You can find a relevant detailed discussion in DeprecationWarning: use setter for headless property instead of set_headless opts.set_headless(headless=True) using Geckodriver and Selenium in Python
References
A couple of relevant discussions: