3 ms·
Right click -> Take a Screenshot
by teamhappy 9y ago
Right click -> Take a Screenshot
- magnetic 9y agoIs there a way to trigger a full screen screenshot via Selenium/WebDriver? (not a partial/window screenshot - that I can do)
- mcintyre1994 9y agoIf I'm understanding correctly, could you just select the body tag and screenshot that? In Selenium Python that'd be: # driver is a Firefox driver body = driver.find_element_by_tag_name('body') screenshot = body.screenshot_as_base64 # png bytes
- magnetic 9y agoJust tried this - doesn't seem to work: - a lot of (visible) elements are missing - the screenshot is still cropped to whatever viewport is used
- mcintyre1994 9y agoDefinitely just speculating here, but there is a `driver.save_screenshot(path)` method that would probably be worth trying. This worked for me: from selenium.webdriver import Firefox from selenium.webdriver.firefox.options import Options geckodriver_path = '/usr/local/bin/geckodriver' options = Options() options.add_argument('-headless') driver = Firefox(executable_path=geckodriver_path, firefox_options=options) url='https://news.ycombinator.com/item?id=16576015' driver.get(url) driver.save_screenshot('./hn.png')
- magnetic 9y agoFirefox has a screenshot feature that I'd like to trigger from Selenium, which is by going through the "..." icon in the URL bar which opens up a menu with its last item being "Take a screenshot" (and then you can select a full page screenshot). Is there a way to programmatically trigger this feature or sequence?
- blauditore 9y agoAlso, there are three dots next to the address bar, where it can be found.
- lizzard 9y agoIf you open that menu with the three dots, then control-click on the Screenshots menu item, you can add a Screenshot button to the address bar.
- odabaxok 9y agohttps://news.ycombinator.com/item?id=16576601 https://news.ycombinator.com/item?id=16576601