Theodoros80
Theodoros80

Reputation: 796

Selenium firefox driver take window screenshot(not fullscreen)

I have a fully working Python script for taking screenshots of webpages using selenium and the FF driver(windows).

The script is taking full page screenshots instead of let's say 1024x768, which make the process slow. Here is my code:

    driver = webdriver.Firefox()
    driver.set_window_size(1024,768)
    driver.get(url)
    driver.get_screenshot_as_file("%s/%s.png"%(screen_dir,o.netloc))
    driver.close()

Any ideas on how to make selenium/firefox take above the fold screenshots and not full page?

Thanks!

Upvotes: 1

Views: 1251

Answers (1)

alecxe
alecxe

Reputation: 473833

This is how the "take screenshot" functionality is working in Firefox - it would take a screenshot of a complete page from top to bottom even if part of it is not visible. This is actually not how it supposed to work by the specification.

Chrome would take a screenshot of the visible area / viewport only. Switch to it.

Upvotes: 2

Related Questions