Using selenium builder to find and verify content in the page source

I needed to test some elements that were being added to certain pages on a web site. I already had some tests that looked for visible page content but no tests that check for elements only visible in the page source.

I am using the json script format used by selenium builder in this example, to do this i used this:

"type": "verifyElementAttribute",
"locator": {
"type": "xpath",
"value": "//link"
"attributeName": "hreflang",
"value": "blah"

The important bit is the xpath value of ‘//link’. I was looking for this string in the page source:

<link rel="alternate" href="awebsite" hreflang="blah" />

The xpath finds the link tag and once this is found i could then test that the hreflang element had the value  of ‘blah’. I can also using the same method test the other parts of the link rel tag.

Hope this help you if your looking to do a similar thing!

dpxdt visual testing tool

A large amount of my time as a tester is spent checking web pages for differences whether they be due to functionality changes or layout and styling changes. Also when a site has  some underlying technology changed or has been moved to a new platform you need to check for changes to the front end look of a site.

I spent quite a lot of time looking for a way of automated this process so i could compare web pages from before and after a change so i only had to check pages that did look different. Its quite a tricky thing to do but i finally managed to find a tool that would do this and the best bit was its free and open source.

This tool once set up (You might need a friendly dev ops to help as its not super easy) you can point it at a page and it will crawl that page and all the links from the page to a crawl depth that you can specify and take screen shots of all of them. This creates your baseline that you will compare against. You then do the same thing against the updated page and once it has completed it will provide you with a list of all the same pages in the crawl that were different from each other. For each set of the same pages it will also identify the parts of the image that are different.

The tool makes a great addition to a continuous integration set up and thats really what its aimed to do but we have it set up just as a stand alone test tool.

It also makes regression testing a whole bunch easier!

Give it a whirl and let me know how your using it!