Save Image

109 views
Skip to first unread message

Gardel Costa

unread,
Jun 8, 2021, 9:05:43 AM6/8/21
to Selenium Users
I need to save image one with Selenium.
My project uses C# and Chromedriver.
On the website, it is not possible to save by clicking with the right mouse button and using the option to save image.
Thanks for the answers!

Gardel Costa

unread,
Jun 8, 2021, 10:22:30 AM6/8/21
to Selenium Users
any answer?

Adrian

unread,
Jun 8, 2021, 6:18:46 PM6/8/21
to Selenium Users
Hi, what are you trying to achieve by doing this?
The right click popup menu, to select the Save Image is a browser action, outside of your control and is therefore not something you should be automating.
Because if this doesn't work, what are you going to do?

If your web site has its own custom popup menu, then you need to use the Actions namespace.


Cheers,
Adrian.

Gardel Costa

unread,
Jun 8, 2021, 8:24:13 PM6/8/21
to Selenium Users
I am not finding options to save images.
What is the most suitable option?

Gardel Costa

unread,
Jun 9, 2021, 7:54:21 PM6/9/21
to Selenium Users

any help?

Gardel Costa

unread,
Jun 10, 2021, 9:43:00 PM6/10/21
to Selenium Users
Any help, please?

Gardel Costa

unread,
Jun 24, 2021, 5:54:34 AM6/24/21
to Selenium Users
any help?

Rii Rii

unread,
Jun 24, 2021, 6:26:01 AM6/24/21
to Selenium Users
Hi,

Hope this helps.

You can create a screenshot function as below, very simple.
 Then create a File Location and copy your file to that location. 
Then convert the image to JPG or whichever format your prefer.
Then while you at it, prefix the filename with a TimeStamp to keep it unique.

   public void takeScreenShot (WebDriver iwebdriver, String pathToFile, String sTitle) throws IOException {
        String formatPNG = "png";
         iwebdriver  .manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        TakesScreenshot iCapScreens = (TakesScreenshot) iwebdriver  ;
        File screenShotFile = iCapScreens.getScreenshotAs(OutputType.FILE);
         iwebdriver .manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    }

Let me know it this is helpful.

Regards,
Riidonesh.

Gardel Costa

unread,
Jun 24, 2021, 6:51:13 AM6/24/21
to Selenium Users
There are several images on the page. Also, it is a site that needs to be logged in to access, so the Webclient option does not work due to the need to login.
So the screenshot doesn't solve this problem.
Thank you very much for your reply.

Rii Rii

unread,
Jun 24, 2021, 8:35:43 AM6/24/21
to Selenium Users
Oh ok. No problem.

I am not an expert at images, but is there any way that you can inspect that XPATH for every image and perhaps read the encoded base64 string and then convert back to an image/s?

Just an idea.
Reply all
Reply to author
Forward
0 new messages