0

Inside selenium + python there is a code that is driver.save_screenshot("screenshot.png") when doing this it saves an image on my system, when deploying on heroku where does this image go and how can I get it?

Linux
  • 150
  • 8

2 Answers2

0

The default location is the same path of the driver. You can find it using the method from this answer.

The location can be changed by providing the full path where the image must be saved, as in the example provided in the save_screenshot documentation:

driver.save_screenshot("/Screenshots/foo.png")

dapmel
  • 16
  • 2
  • I still don't understand how this can help me to get the image. – Rodrigo Carvalho Jul 22 '23 at 20:38
  • Well, you can access the storage and retrieve the images, right? Also, the app storage is ephemeral and you will need to [store the files in a dedicated file service](https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted-from-the-application) if you want the screenshots indefinitely. – dapmel Jul 22 '23 at 21:19
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 26 '23 at 11:41
0

I've been doing some research and I believe that Heroku forces users to use cloud services to save files, such as Amazon S3, but I figured a little creative way to solve this.

The function driver.get_screenshot_as_base64() extracts the base64 of the image, you can structure a separate backend to send this base64 and structure it again in an image in the front or as you wish and possibly even saving it in your favorite database.

Advantages: Does not depend on third-party service.

Disadvantages: You will need a separate server for this support. (In theory you don't need it, you can use the same one, but the two can have applications so different that they are not worth the risk.)

Alexandre Juma
  • 3,128
  • 1
  • 20
  • 46