I'm trying to screenshot a specific web_element using screenshot_as_png
method but an error is being raised. Everything works fine when I run this program on my Windows 10, but it fails on my AWS EC2 Ubuntu 18.04
main.py
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--disable-notifications')
options.add_argument("headless")
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--disable-gpu")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--no-sandbox")
chrome = webdriver.Chrome(options=options)
chrome.get('http://stackoverflow.com/')
element = chrome.find_element_by_css_selector('.-main.grid--cell')
element.screenshot() #Error!
chrome.quit()
The error is the following:
selenium.common.exceptions.WebDriverException: Message: unknown command: session/5c9bda106805d0d80a3f5c7b63dbf410/element/0.35398631812343306-1/screenshot
The setup I'm using:
(Session info: headless chrome=80.0.3987.87)
(Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 4.15.0-1060-aws x86_64)