This post is related to this one:
Python selenium screen capture not getting whole page
The solution with PhantomsJS seems to be working:
driver = webdriver.PhantomJS()
driver.maximize_window()
driver.get('http://www.angelfire.com/super/badwebs/')
scheight = .1
while scheight < 9.9:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight/%s);" % scheight)
scheight += .01
driver.save_screenshot('angelfire_phantomjs.png')
However the solution is from 2014 and PhantomJS is meanwhile deprecated. I'm getting namely this error message:
...
UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '
If I try to adapt to e.g. Firefox headless like this:
from selenium import webdriver
firefox_options = webdriver.FirefoxOptions()
firefox_options.set_headless()
firefox_driver = webdriver.Firefox(firefox_options=firefox_options)
firefox_driver.get('http://www.angelfire.com/super/badwebs/')
scheight = .1
while scheight < 9.9:
firefox_driver.execute_script("window.scrollTo(0, document.body.scrollHeight/%s);" % scheight)
scheight += .01
firefox_driver.save_screenshot('angelfire_firefox.png')
a screenshot is made but not of the whole page.
Any ideas how to make it work with Firefox or Chrome headless?
(P.S. I also found this post:
Taking Screenshot of Full Page with Selenium Python (chromedriver))
but it doesn't seem to be a general solution and it is much more complicated.)