Capture multiple Images with different Name in Selenium Webdriver in Java eclipse

2,369 views
Skip to first unread message

Rajesh Upase

unread,
Dec 5, 2013, 11:15:46 PM12/5/13
to seleniu...@googlegroups.com

Capture the screenshots that You would need to copy the file somewhere else with a different name. The following code help to you.

Create the method of any name. I am creating here captureScreenshot method.

public static void captureScreenshot(String path) throws IOException{
    try{
        File scrFile= ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

        FileUtils.copyFile(scrFile, new File(path) );

    }
    catch (Exception e){
        System.out.println("Failed to capture screenshot");
    }


}

Then use this method in your method where you want to take the screenshots. Refer the following line of code. Here I am using the system current time in milliseconds for to save the multiple Images with different name.

captureScreenshot("././screenshots/loginerror_" + System.currentTimeMillis()+".jpg");

Pavankumar Nagaraj

unread,
Dec 16, 2014, 5:03:40 AM12/16/14
to seleniu...@googlegroups.com
Hi Guys,

I found following useful link in Github to take MultiScreenShot

Krishnan Mahadevan

unread,
Dec 18, 2014, 3:52:21 AM12/18/14
to Selenium Users
This logic makes use of the Robot classes, which I believe may not work when using the RemoteWebDriver, because AFAIK Robot triggers actions on the machine where the JVM is running and may not do it on a remote host (where your actual test would be running when working in the Grid mode)

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6aa4e847-643e-4cba-95a7-363644db0935%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages