Automated Testing - Getting Started with Selenium IDE
13 Aug 2015What is Selenium IDE?
Selenium is an add-on for Firefox that allows the user to automate interactions with the browser. It can be a great testing tool for a developer or QA/test engineer.
Download and Install Selenium IDE
Download Selenium IDE for your Firefox browser. The Selenium IDE icon will display in your Firefox toolbar once installed.
Let’s create a simple test case.
Go ahead and fire up Selenium by clicking the icon in the toolbar. You should see the following window appear.
Enter the domain in the ‘Base URL’ field.
Create a command of ‘open’ with a target of ‘ / ‘. This will open up the website to the homepage.
Double click the line you just created and it will open the homepage in Firefox.
Now that we have the site open, we need to get Selenium to listen to us as we conduct a site search. In selenium, click the record icon.
Conduct a site search with a keyword of ‘Hotel’ or ‘Spa’. We will expect search results for these common keywords if the site search is functioning correctly.
Notice that Selenium recorded our actions as we interacted with the website. You should see new commands automatically added to our test case. Don’t forget to click the record icon again to stop recording your actions.
Select the ‘Play Current Test Case’ button to see the commands navigate the site again.
Now that our test case can conduct a site search we need to add a command that tells us if it fails or passes. Since we know those common keywords should display some search results, this test can verify that the ‘No Results Found’ message does NOT display. Add a command of ‘verifyTextNotPresent’ with a target of ‘No Results Found’. Run the test case. If it passes, it should look like this…
A failing test case would look like this…
Important Note
I’ve found that Selenium IDE is great for high level testing like the example above. It doesn’t replace Unit Testing by any means. Automatic testing through the UI can be a little unpredictable and generate a large number of false positives. However, when it comes to grindy tasks like filling in a form for the millionth time, Selenium is awesome.