1

I'm taking screenshots of elements in Selenium using the Firefox driver's element.screenshot_as_png. The resulting images include other elements that are underneath, as well as a white background behind everything (even though the page has no background colour set).

I just want the element alone on a transparent background, nothing else. According to this answer there's a way to do it in Chrome. Any chance to get the same thing with Firefox?

kontextify
  • 478
  • 5
  • 16

1 Answers1

0

You Can Take Screenshot Like That!

driver.get_screenshot_as_png()

You Can Also Use Pillow!

import pyscreenshot
im = pyscreenshot.grab()
im.save('ss.png')
Hamza Lachi
  • 1,046
  • 7
  • 25
  • Thanks, but I need to screenshot a specific **element**, not the entire window. Also those methods don't handle overlapping elements and transparency. – kontextify Nov 14 '19 at 11:59