I try do it
from selenium import webdriver # $ pip install selenium
from selenium.webdriver.chrome.options import Options
DRIVER = 'C:\selenium\chromedriver.exe'
driver = webdriver.Chrome(DRIVER)
options = webdriver.ChromeOptions()
options.add_argument('headless')
options.add_argument(f'window-size={1920},{1080}')
options.add_argument('hide-scrollbars')
# get chromedriver fro
#
https://sites.google.com/a/chromium.org/.../downloads
browser = webdriver.Chrome(chrome_options=options)
browser.get('stackoverflow.com')
browser.save_screenshot('filename.png')
but I have an error
==========================================================================
C:\Users\Professional\PycharmProjects\automtest\venv\Scripts\python.exe C:/Users/Professional/PycharmProjects/automtest/diferents.py
C:/Users/Professional/PycharmProjects/automtest/diferents.py:13: DeprecationWarning: use options instead of chrome_options
browser = webdriver.Chrome(chrome_options=options)
Traceback (most recent call last):
File "C:\Users\Professional\PycharmProjects\automtest\venv\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Program Files (x86)\python\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files (x86)\python\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Professional/PycharmProjects/automtest/diferents.py", line 13, in <module>
browser = webdriver.Chrome(chrome_options=options)
File "C:\Users\Professional\PycharmProjects\automtest\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\Professional\PycharmProjects\automtest\venv\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see
https://sites.google.com/a/chromium.org/...river/home
Process finished with exit code 1