1

I want to be able to screenshot a page and send that file in an email. For example, if manually i screenshot this page using the PrtSc function on the keyboard and I go to my email text box all i have to do is CONTROL V to paste it there and send. Is there a way I was do something like this using selenium?

I can currently screenshot using this function

driver.save_screenshot('screenie.png')

However, it doesn't do what I want it to. It just screenshots and saves the file in the folder.

sa7
  • 47
  • 1
  • 10

1 Answers1

2

Well, .save_screenshot() does exactly what it is supposed to do - takes a screenshot of the browser page and saves it in an image file.

Now, if you want to further send this file as an attachment over email, you can use smtplib:

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • What if I wanted to screenshot and paste and send on like facebook. Is there a way to do that automatically using selenium. – sa7 Jun 22 '17 at 18:16
  • @sa7 you can do facebook posting via `facebook-sdk` graph api, sample here: https://stackoverflow.com/a/43476182/771848. Hope that's what you meant. – alecxe Jun 22 '17 at 18:20
  • @sa7 you can, of course, navigate to facebook in your selenium automated browser, log in and post, but that's a lot of overhead. – alecxe Jun 22 '17 at 18:21
  • Thanks a lot @alecxe. I also want to be able to send a screenshot as a message on facebook. is that also possible? – sa7 Jun 22 '17 at 18:35