testing for the presence of an image with selenium
If you want to test for the presence of an image in a page using selenium, the best way to do this is by using the assertAttribute function. This function takes two parameters: an attribute locater and a pattern to which it should match. So for the following HTML…
<html>
<body>
<img src="http://192.168.1.163/files/rous.jpg"/>
<body/>
<html/>
You can check that the image is there by calling “assertAttribute” with “//img@src” and “http://*/files/rous.jpg” as your params. This of course is only checking the HTML. If the image file actually doesn’t exist on the server and is displayed as a lovely red x in the browser, selenium will happily pass this test case.

