1

I use seleniumjs to automate my tests

Is there a tool which can find an element on a page by its image? Or just assert that an image is present somewhere on a page

I know Sikuli in Java can do such things. I just wonder if there is smth similar that I can use in javascript

1

It's not the prettiest, but you can store images of what you expect. Then use the selenium screenshot utility to capture a new image and then compare the two images for an exact match. The difficulty there is you need to store the images exactly how selenium takes them as there are limited options with the screenshots. It won't scale as well as Sikuli that will just look for the image anywhere in existence, this would lock to the exact same behavior.

Here is a good reference for beginning screenshot usage: https://stackoverflow.com/questions/3422262/take-a-screenshot-with-selenium-webdriver

a few tips:

  1. I found dynamic screenshots to be a bit tricky and tempermental as they snap before the page actually loads...I'd recommend putting a wait for the last object you are aware of that loads and then snap the screenshot.
  2. It also includes object snapping as well as full page...you would just have to find the object first or have specific coordinates.
  3. Please be mindful that you are using graphics which is bound to the graphics card and screen resolution, so in this case they need to match or the image recognition won't work this way either.
  4. Lastly the type of image is important, you need to ensure every aspect is identical otherwise it won't match.

As you can see this is why Sikuli is so awesome and if you need that adaptability I'd recommend actually integrating sikuli with your test through command line calls that kick off the Sikuli test. Up to you, if you hit more specific situations post more specific questions. Good Luck!

  • You can also use a bunch of paid ones, but the image concept is the same as the one mentioned for selenium use...you just don't have to program it yourself. Personally with testing, I'd just capture all the images and physically just skim them for bugs with someone who knows the app. The human eye and brain is extremely fast with image recognition...just automate the image capture part for review. – mutt Aug 26 '16 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.