How to compare 2 images using webdriver

1,761 views
Skip to first unread message

srujana rambabu

unread,
Sep 23, 2014, 6:15:15 AM9/23/14
to webd...@googlegroups.com
hi all

can any one help me how to compare 2 picture images by using webdriver
i took the screenshot of required image by using the code

                File scrnshot=((TakesScreenshot)wd).getScreenshotAs(OutputType.FILE);
File dest=new File("F:\\sele screenshots\\image2.png");
FileUtils.copyFile(scrnshot, dest);

before this i took one more screenshot of same image manually and saved it in system.

now i want to compare these 2 images are same or not?

is this possible?

thanks for your help

Krishnan Mahadevan

unread,
Sep 23, 2014, 6:26:11 AM9/23/14
to webdriver
And why do you think that image comparison has anything to do with Selenium/WebDriver? 

Please google up for "Image comparison using Java" and you should get answers for your questions on your own.

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 "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.

darrell

unread,
Sep 23, 2014, 8:51:01 AM9/23/14
to webd...@googlegroups.com
Selenium is not a full test solution. It is a tool used to drive the browser. A browser does not have the ability to compare images. So Selenium does not have the ability to compare images. Essentially, tools like HP Quality Center try to provide you with everything you need to test a web application. This is why it is not free. However, as technology evolves you are at the mercy of HP's roadmap. If I used tools like Java, JUnit, Selenium, JDBC, etc. and craft my own solution, when encountering a new technology (like AngularJS) I don't have to wait for HP to develop the support for it. It does however require me to know more about whatever technology I am trying to tackle.

If you don't know how to do image comparison in Java then you are going to have to learn or find/hire someone to handle it for you (or teach you). If you want to tackle this yourself, as Krishnan suggests, you'll need to search for solution to "Java image comparison". Otherwise, you'll need to find someone to provide a solution for you.

Darrell
Reply all
Reply to author
Forward
0 new messages