Day 6 of the 30 Day Writing Challenge
I, unlike most of the Tag Soup group, am not a developer. I’m currently a Web Tester at melt media and have held other QA titles at other organizations. QA is here to help you make better and higher quality products. This is usually accomplished through two methods: manual testing and automated testing. This post will concentrate on providing an introduction to automated testing using Selenium and Ruby. Foreword before we get to any code: I’m still new to writing Ruby code.
First you’re going to need to have Ruby installed. If you don’t already, follow this guide. Once that is accomplished you’ll need to install the Selenium webdriver gem.
One more note before we get further into the code. Automation is not a replacement for manual testing. Anyone that tells you this is lying. This post is going to cover using Selenium to automate link verification on marketing sites. This seemingly innocuous test is very critical, and often overlooked in manual testing.
1 2 3 4
This will create the object Page, which at this moment is a blank firefox window. Loading any specific page is done by calling the Get method on that object.
Your browser should now be on the meltmedia homepage. Now let’s make objects for each link. I’m going to be finding the elements by the link text. You should truthfully use :id, :class, or xpath where applicable as they’re less likely to change than the copy of a page.
You should now be on Melt’s portfolio page. Now we have to check that the proper page loaded. You can do this a number of ways. You can search for specific elements, check the page title, or look for specific copy. At the same time I’ll have the test output the results to the terminal. You can output to a text file if you’d like as well.
1 2 3 4 5
We now have a simple test that verifies a link. We can use this test as a template for other link verification tests. Either by making one long script that runs through ever links, or scripts for each individual links. I prefer the later because it gives you granular results and lowers the chance of failure. Since each test is independent of the previous, one test failing can’t cause another test to fail as well.