selenium-cucumber : Image Comparing Steps

Now easily compare images/logos from website under test using

Image Assertion Steps

Pass appropriate locator of “actual image” and URL of “expected images” (which you can store on some server) to following steps to compare images/logos from testing website :

Then actual image having id "(.*?)" and expected image having url "(.*?)" should be similar
Then actual image having name "(.*?)" and expected image having url "(.*?)" should be similar
Then actual image having class "(.*?)" and expected image having url "(.*?)" should be similar
Then actual image having xpath "(.*?)" and expected image having url "(.*?)" should be similar
Then actual image having css "(.*?)" and expected image having url "(.*?)" should be similar
Then actual image having url "(.*?)" and expected image having url "(.*?)" should be similar

Pass appropriate locator of “actual image” and image name of “expected images” (which you can store locally on you machine under “expected_images” folder in feature skeleton) to following steps to compare images/logos from testing website :

Then actual image having id "(.*?)" and expected image having image_name "(.*?)" should be similar
Then actual image having name "(.*?)" and expected image having image_name "(.*?)" should be similar
Then actual image having class "(.*?)" and expected image having image_name "(.*?)" should be similar
Then actual image having xpath "(.*?)" and expected image having image_name "(.*?)" should be similar
Then actual image having css "(.*?)" and expected image having image_name "(.*?)" should be similar
Then actual image having url "(.*?)" and expected image having image_name "(.*?)" should be similar

To compare two images from same webpage you can make use following steps.

Then actual image having id "(.*?)" and expected image having id "(.*?)" should be similar
Then actual image having name "(.*?)" and expected image having name "(.*?)" should be similar
Then actual image having class "(.*?)" and expected image having class "(.*?)" should be similar
Then actual image having xpath "(.*?)" and expected image having xpath "(.*?)" should be similar
Then actual image having css "(.*?)" and expected image having css "(.*?)" should be similar
Then actual image having url "(.*?)" and expected image having url "(.*?)" should be similar
  • If any difference appears in actual image and expected images then difference between images will be highlighted and stored in “image_difference” directory in feature skeleton. (Note : This feature works only for PNG images.)
  • You can avail “Image Assertion Steps” for gem version 1.1.1 and above.
  • From gem version 1.1.1 and above feature skeleton is slightly changed. We have introduced four more directories “expected_images”, “image_difference”, “actual_images”,”screenshots” in feature skeleton.

Video tutorial about how to use image assertion steps.

Advertisement

About Sameer Sawant

I am postgraduate in computer science from pune university. Working as QA Engineer in an IT company.
This entry was posted in selenium-cucumber ruby and tagged , , , , , , , . Bookmark the permalink.

2 Responses to selenium-cucumber : Image Comparing Steps

  1. MOhan says:

    for jpg how to check it ..

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s