Webdriver and Image Verification

Image Verification

Can you do image verification if it loaded on webpage?

 Yes! You can verify but you cannot say that images are half loaded. To verify if an image is correct then there would be some other method but the code will tell you just that images are loaded on the page or not.

You can send HTTP request to that source using GET method and check the status code as 200. if that the case then your image downloaded properly and an image is there. 

Please drop your comments if you think if I am missing anything. If you have another idea to do image verification, please comment.

19 Replies to “Webdriver and Image Verification”

  1. I want to capture “Months of Supply” report from below URL

    Please let me know is it possible? and how?

    1. Anand, its not possible to verify as far as I know for now. you can verify till “region-content” as its AJAX.

  2. Can we compare/verify the content of downloaded pdf?

    1. Nope! selenium can read only HTML DOM.

      1. Is it possible to read un-rendered content and perform action on it? For Ex.) I have a table with 100 columns in which the grid first displays only 50 columns and upon scroll only the other remaining columns will be displayed. So here first 50 columns and rows only visible in the DOM, the remaining will be visible in the grid only if user scrolls right/left.? Please let me know the feasibility of this using selenium or any other automation tool.

  3. HI everyone,
    Regarding verification of the downloaded pdf content, i would like to share my current working with you guys,.Well i am writing the automation framework with MySQL support in selenium RC java now a days.I also have to find the solution where we can compare or verify the downloaded pdf content with our verification points. . So after thinking a lot and studying the selenium API, i come to the decision that we need to introduce a parser here with the help of some java code which can help in the situation. Well i am not sure if it works or not, I am still under progress of some kind of POC. You can also think on these lines. May be this will resolve your problem.

    1. I am kind of agree with you but we should keep in mind that verifying image or pdf is not under scope of Selenium but programming language whatever we are using.

  4. Your code doesn’t work. Pretty obvious when you look at it

    1. It’s working for many and for me as well. Let me know where you find not working.

  5. Awesome Article, I love the excel one very much. Keep doing good work.

  6. In order to do visual verification, you can use ‘Microsoft.Test.VisualVerification’.
    All you need to do is have a copy of the expected image and then click a snapshot of the browser and get the actual image and then use VisualVerification to assert your results.

    This technique is very reliable and you can also set tolerance levels if required to assert your result.
    Hope this is helpful, mail me if you require any assistance with Visual Verification.
    [email protected]

    1. Interesting Syed. but can you compare using program? I found this http://codereview.stackexchange.com/questions/39980/determining-if-2-images-are-the-same which can be useful too.

    2. Hi Syed,
      Is it possible to verify whether the logo displayed in the screen as actual logo which i am expecting?

  7. Can we verify the region exists in the web page through webdriver code?

    1. Hi Abdullah,
      What kind of region are you talking about? If you like to verify inside image then not possible but you just want to verify image as a whole then you are good to go and use above or similar code. Let me know if you were asking something different.

  8. Nice Blog !!

  9. I need the code in selenium WebDriver Junit. I have a test case working on, which is related to this type of below question.

  10. Thank You verymuch, exactly what I was looking for…!!!

Leave a Reply