- Download your Selenium IDE from Selenium HQ
- This IDE is actually a plugin for FireFox. While you can play your tests back in multiple browsers
- You can also install the plugin by opening FireFox and installing the Extension “Selenium IDE”
OK, those are the parts, let’s get busy with an actual test. We’llkeep it simple and start with a single testcase.*For the following instructions, things in RED should be steps that you take in FireFox. Items in BLUE are steps that you’ll take in theSelenium IDE window.
- Open Firefox to www.google.com
- Open Selenium IDE by going to “tools” and clicking on “Selenium IDE”
- Verify that your Base URL is set to “http://www.google.com”
- In the search bar, type “Eddy Jones” and hit [ENTER]
- Click the first link that will take you to estevenjones.com
- Highlight the title “The Blog” on the estevenjones.com home page
- Right click on the highlighted text and select “VerifyTextPresent The Blog” (this is one of the new Context Menu items that was added when you installed the Selenium IDE
- Click “Hubble Space Telescope” link in the story about the Hubble Space Telescope (or any other link on any other story)
- Right click on one of the images and hover over “Show All Available Commands >” and from there, select “AssertElementPresent <some identifier here>”
WHAT??? Why did my tests fail??
Well, your tests probably failed here, but that’s ok. This really demonstrates the speed of Selenium. Your test most likely failed because Selenium tried to move on to the next step before the web page finished rendering. So it tried to click on your next link before the link was actually on the page. There are two ways to handle this. The quick but bad way would be to adjust the speed of your test by adjusting the slider on the toolbar. This would allow the web pages a chance to render prior to Selenium trying to act on it. The better way to handle this would be to change the “click” commands to “ClickAndWait” commands, though. This way, Selenium will wait for the page to completely render before moving on to the next command. One thing to note about this method, however, if you are testing a page that has frames, you might run into problems withFireFox. FireFox says the page is completed once the Frameset is complete rather than waiting for the contents of the frame have completely rendered.
Also before I sign off for this first tutorial, I’ll mention the difference between Assert and Verify
When you ASSERT that an element is present, you are telling Selenium to stop the test and proceed no further if the assertion is not valid. So, if I assert that an image is present and that image is NOT present, Selenium will not move on and all testing will stop. The test will be marked a failure.
When you verify something is present, you are looking for something that is not terribly important enough to stop the entire test if it’s not.
An example of when I might use assert versus using a verify:
If I loaded a web page displayed a render time, I might want to verify that the render time was under 5 seconds, but I wouldn’t necessarily think that it’s a total failure if it took 6 seconds to render. I would want to use an assert to verify that it didn’t take longer than 10 seconds because 10 seconds is way past my threshold for acceptable render times and there is no point in continuing my tests if it takes longer than that.