How to test that certain images will show up when a page is loaded?
Top  Previous  Next

Q: I want to test that certain images will show up on my site when a page is loaded.

A: You can use the Save Item function for this. If a image is missing, an error will occur. Example:

CLEAR
URL GOTO=http://www.iopus.com/imacros/demo/v4/images/test-image-loaded 
TAG POS=1 TYPE=IMG ATTR=TXT:<IMG<SP>height=90<SP>src="bee.jpg"<SP>width=90<SP>border=0> CONTENT=EVENT:SAVEITEM
TAG POS=1 TYPE=IMG ATTR=TXT:<IMG<SP>height=90<SP>src="shark_thumbnail.jpg"<SP>width=90<SP>border=0> CONTENT=EVENT:SAVEITEM


This macro will download two images. If one image is missing on the web page, the macro stops with an "image not found" error. To make sure that the missing image is not stored in the browser cache, it is recommended that you use the
CLEAR command before this test.

This technique is also recommended if you are automating or testing web sites with complex frames. To make sure a specific frame is completely loaded, do the above test for a specific image in this frame. iMacros will wait at the
TAG.....EVENT:SAVEITEM command until this image appears.

The above method is easily implemented if you have information about the image such as its own URL, the link URL or the alternative text. If all you have is the image itself, use the
IMAGESEARCH command of the Image Recognition Plugin.



Page URL http://www.iopus.com/imacros/help/faq_test_image.htm