RE: How to verify the Changing Images in a Website using Selenium Webdriver
I’d like to suggest a general and more robust approach towards such dynamic behavior.
I dislike using waits and timeouts in hope that something will be ready – it’s error prone and the best results are achieved by a bit of cooperation with the developers.
What the developers need to do is:
– when the URL contains a special query parameter – for example /?test=true – the application/site is under test mode.
– In test mode – a child element called <test> is appended under the <body> element.
– To use you images example – whenever an image is being displayed – a test event is sent to announce it – and the image is not changed until the event is handled.
– Test even is sent by adding a child element under <test> element. You test code reads the element, handles it and deletes it – allowing the image gallery to move on.
You might get away with simple timeouts when doing functional testing – but once you start running visual tests and take screenshots you’ll need the ability to “pause” the site’s state until you’re done and ready to move on.