About Selenium IDE
Familiarity with the products of Selenium is better to start with Selenium IDE.
To begin, you must install browser Mozilla Firefox.
Next to "Tools" -> "Add" to find an addon Selenium IDE and install it. After installing and restarting the browser can start recording their first test.
For clarity, let our first self-test verifies the availability of the site gmail.com and availability on its opening page of certain records.
- "Tools" -> "Selenium IDE" – should see a window with a constructor tests
- Open a new tab and type in the address bar http://google.com
- Go to the IDE and fill in the field of Basic url "values" http://google.com "
- Start recording test by clicking on the red circle
- Tab to Google and click on gmail – as a result of IDE should write to us first-team self-test:
open /
click link = Gmail
- Criterion for the success of the test for simplicity, we choose the fact of the inscription on the resulting page, "Welcome to Mail Gmail". To write a test, click this check, right-click on ‘Welcome to Mail Gmail "and click on" verifyTextPresent (….)" – this action will add to the script your self test checks the command appropriate scientific. For the first test enough checks!)
- Stop the recording test by clicking on the red circle.
- Verifies that the test by pressing the button with the hint "Play current test case" (keep in mind that the IDE runs the test in the current active tab:) – as a result most likely you will see that the test is not passed (the red line "false")
What’s the matter? After all, we test drove the same utility, which he and recorded!
The reason is that the IDE has recorded a test script, click click, carrying the driver of the tests are not dolzhidaetsya download new content browser, and immediately executes the following command (we are verifyTextPresent). It is clear that the instant the page is not loaded, even at very high speed connection, and, therefore, at the time of check text, it’s not in the nature (ie, in the browser) and the test fails. To this test was to replace the team click on clickAndWait. It must be done manually. Click on the team and edit the field "Command", replacing the string "click" on "clickAndWait". Bug or a feature is IDE? Rather, "implementation detail", because in some cases need a really click.
- Chase a written test again and see that this time it was held successfully.
I note that the IDE is the ability to configure a timeout for the download page. By default this timeout is 30000 milliseconds. That is, the test will fail if, within 30 seconds. from Google is able to get a page with the desired inscription.
The resulting test can be saved to a file, and even export some of the most popular high-level programming languages: java, c #, perl. In their daily work activities, I am dealing with perl, so one of the following posts I will describe how to programmatically work with selenium, using perl.
Writing Tests using Selenium IDE from time to time you will be confronted with the fact that not everyone knows how to do it automatically and does not automatically make everything as is necessary for you (see example above). I can only say that we can always add the command manually and you can always find the necessary elements of html-pages by using Xpath. For poluchaniya correct use xpath extension supplement Firebug. Well, if there are difficulties with this, please – try to help.
This, of course, not everything that can be implemented using this IDE. Supported by a great number of commands with which smozhno simulate virtually anything that can make the user hands in your browser.
See Also