Description
While creating a Web Test Case, there may be a need to validate that an image on the page loads correctly.
Solution
At the necessary location in the Web Test Case, add the following step:
Step type: Function
Step contents: Contains(null, "IMG_NAME.IMG_EXTENSION", null, "document.querySelector('ID_OR_CLASS_SELECTOR > img').src");
Where IMG_NAME.IMG_EXTENSION is the full name of the image including the extension and ID_OR_CLASS_SELECTOR is the selector from the web page code.
Example:
Step type: Function
Step contents: Contains(null, "https://s3.amazonaws.com/visualivr/Production/9.4.5.8/CoreImage/TestPage.png", null, "document.querySelector('#cxpTitleH1 > img').src")
Where https://s3.amazonaws.com/visualivr/Production/9.4.5.8/CoreImage/TestPage.png is the full name of the image including the extension and #cxpTitleH1 is the selector from the web page code.
Note: The scripts above have to be modified depending on the web page code.
Comments
0 comments
Please sign in to leave a comment.