0

I'm trying to open Chrome in non-headless mode with an extension enabled to take a full page screenshot. When I remove headless mode, the extension works but the taken fullscreen is not for the full page. Without headless mode, the extension cannot be loaded.

I came across this answer which mentions that it is not possible without headless option. However, extensions cannot be enabled in headless option.

Take screenshot of full page with Selenium Python with chromedriver

here is my current code. Is there away to do this?

print("Taking screenshot for {}".format(link))
options = webdriver.ChromeOptions()
options.add_extension('./chromedrivers/AdblockPlus.zip')
options.add_argument("--disable-notifications")
#options.headless = True

driver = webdriver.Chrome("{}/chromedrivers/{}".format("macDriver"),options=options)
driver.implicitly_wait(1)

driver.get(link)
S = lambda X: driver.execute_script('return document.body.parentNode.scroll'+X)
driver.set_window_size(S('Width'), S('Height'))                                                                                                             
driver.find_element_by_tag_name('body').screenshot(f'./screenshots/{name}.png')
ifreak
  • 1,726
  • 4
  • 27
  • 45
  • I think there are tools that claim to take full page screen shots (like https://github.com/assertthat/selenium-shutterbug perhaps) – DMart Mar 10 '21 at 18:18
  • Sorry, removed my answer. Misunderstood and didn't see that you explicitly wanted it in non-headless mode – tbjorch Mar 10 '21 at 19:00
  • @DMart it seems that this library is only in Java? – ifreak Mar 11 '21 at 07:20

0 Answers0