Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Screenshot web page !
#3
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
Reply


Messages In This Thread
Screenshot web page ! - by ABVSVL - Jul-10-2020, 03:57 PM
RE: Screenshot web page ! - by snippsat - Jul-10-2020, 04:41 PM
RE: Screenshot web page ! - by ABVSVL - Jul-11-2020, 01:04 PM
RE: Screenshot web page ! - by snippsat - Jul-11-2020, 01:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Taking screenshot ConsistentlyInconsistent 1 1,138 Sep-10-2023, 11:20 PM
Last Post: Larz60+
  Flask Can't Save Screenshot to Postgres Db firebird 3 2,423 Sep-21-2020, 09:22 PM
Last Post: firebird
  Store Screenshot Selenium + MongoDB Nuwan16 9 3,694 Aug-18-2020, 03:57 AM
Last Post: ndc85430
  screenshot arezoo 3 2,406 Apr-11-2020, 10:22 AM
Last Post: buran
  use Xpath in Python :: libxml2 for a page-to-page skip-setting apollo 2 3,675 Mar-19-2020, 06:13 PM
Last Post: apollo
  selenium screenshot hai001 18 14,142 Feb-25-2017, 06:22 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020