chromedude
chromedude

Reputation: 4302

How would you verify that a certain css element on a page is a certain image with selenium

I have a page that I want to check with selenium that uses a certain background image for one element. I want to ensure that this image still exists on the page connected to the element. How would I do this with selenium. If this changes anything I am using browsermob.com to do the testing once I get it running through selenium ide.

Upvotes: 0

Views: 521

Answers (1)

Hannibal
Hannibal

Reputation: 1127

Well aside from the suggested things on the almos duplicate issue... You could check if the property of your body element is set to the image.

By if getAttribute returns a valid value or not. Like:

new Wait()
    {

        public boolean until()
        {
            return selenium.getAttribute("ElementLocator")
                + "@class").equals("active");
        }
    }.wait("The menu item did not get active.",
        defaultTimeOutValue);

This will wait for the attribute @class to have the value "active".

Or simply use an If statement after you are sure that the page got loaded.

Hope this helps, Cheers, Gergely.

Upvotes: 1

Related Questions