Selenium IDE Tutorial – Part 1

Selenium IDE is an integrated development environment for performing Selenium tests.  Selenium tests can be written as HTML tables or coded in various languages like C#, PHP, Perl, Python and can be run directly in most modern browsers.The IDE can help you to record, edit and debug tests. Currently the IDE is only available for Firefox (as if we developers will use any other) as a addon.

Here is a possible scenario for using Selenium. Imagine you have created a HTML form with about twenty fields and you have to repeatedly test the form. Filling the form every time can quickly become tedious. With Selenium you can automate the whole process and run the test as required. In this part we will see how to create a simple test in Selenium. So let’s get started.

STEP 1 – installation :

You can download Selenium IDE from this locations.
http://selenium-ide.openqa.org/download.jsp
https://addons.mozilla.org/en-US/firefox/addon/2079
Once the addon is installed make sure you do not forget to restart Firefox.

STEP 2 – running a simple test :

a. Start Selenium IDE  in Firefox: Tools->Selenium IDE. You will see the following popup.

selenium

b. Click on the red record button on the right.
c. Browse to Google.com and enter ‘selenium’ in the search box and click enter.
d. Click on the first result, which is that of selenium.openqa.org.
e. Stop the recording by clicking on the record button.

You should see something like below. If you click on the ‘ Source’ tab you can see the test html generated by selenium.

selenium ide

The ‘table’ tab shows the commands recorded by Selenium.

f. Open a new tab in Firefox and click on the Selenium IDE’s play button to run the recorded test.

selenium ide

The IDE should play your recorded test. After the test is complete you should have landed on the selenium page (http://selenium.openqa.org/). The IDE after the test run is shown below. In the ‘Log section’ you can see the various events run by the test. In the table tab you can see that all the rows are green, which means that the test ran successfully.

selenium test run

Now lets add a small assertion to the above test.

a. Click on the blank line below after the last ‘clickAndWait’ command and insert ‘assertTextPresent’ command from the drop down box as shown below. You should see something like this.

This test checks to see if the text ‘Selenium News’ is present in the last rendered page. Run the test again and you should see that the test has run successfully. No try replacing the text with something that is not present on the page, take for example ‘elvis’ and run the test again. Now the test fails and you should get the screen below.

You have just completed your first test run. And it was so simple.

‘assertTextPresent’ is one of the hundreds of commands available for your testing needs. Just browse throught the command drop down to get a feel of what you can you get.

In the next part we will see more advanced features of Selenium.



62 thoughts on “Selenium IDE Tutorial – Part 1

  1. Hello Sameer
    New to this but will learn, reading all kind of info, but seems you are the Master.
    My problem is on the site i am testing navigation header has a link to a pdf when i click on the pdf it opens but selenium gives an error

    [warn] Link has target ‘_blank’, which is not supported in Selenium! Randomizing target to be: selenium_blank18660

    when the pdf opens in another window a new browser window opens untitled

    i tried to insert a go back with link but still no luck, can you please help

    [warn] Link has target ‘_blank’, which is not supported in Selenium! Randomizing target to be: selenium_blank18660

  2. sameer

    Thank you so much that did the trick, now i have another issue, i saw it on the google selenium users but no answer.

    I was able to open the pdf page with no error but now i am trying to close it and go back to the original page

    I did a
    close
    http://www.vyvanse.com/pdf/prescribing_information.pdf

    and

    close
    http://www.vyvanse.com/pdf/prescribing_information.pdf

    and got this error

    close
    http://www.vyvanse.com/pdf/prescribing_information.pdf

    What am i doing wrong.

    Thanks

  3. Hello sameer

    i read my own post and made no sense at all, sorry Sir.
    My problem is now i am trying to close the pdf’s i opened and hace use close or windowselect and i am still getting errors.

    this is where i am

    Focus euro stage

    Focus euro stage

    open
    https://vyvansefocus-b.erweb.eurorscg.com/

    openWindow
    http://www.vyvanse.com/pdf/prescribing_information.pdf

    selectWindow
    null

    openWindow
    http://www.vyvanse.com/pdf/medication_guide.pdf

    selectWindow
    null

    open
    https://vyvansefocus-b.erweb.eurorscg.com/Register.aspx

  4. I have downloaded and installed the latest Selenium IDE dated March 26, 2010. However, when I start using it, the “Table” tab is disabled and the other functions are ALSO disabled. The only option available is the “Record” icon.

    Is there something wrong or did I install it incorrectly?

  5. Hello Sameer

    I have been trying to close 2 pop up windows and i am having trouble identifying them in order to close them , can you please help. Thanks

    open
    https://vyvansefocus-b.erweb.eurorscg.com/

    assertTitle
    Vyvanse® (lisdexamfetamine dimesylate) CII Patient Support

    openWindow
    http://www.vyvanse.com/pdf/prescribing_information.pdf

    selectWindow
    http://www.vyvanse.com/pdf/prescribing_information.pdf

    close
    http://www.vyvanse.com/pdf/prescribing_information.pdf

    openWindow
    http://www.vyvanse.com/pdf/medication_guide.pdf

    selectWindow
    http://www.vyvanse.com/pdf/medication_guide.pdf

    open
    https://vyvansefocus-b.erweb.eurorscg.com/Register.aspx

    this is the error i a am getting and i have not been able to figure out how to close the 2 pop up windows that are in the format of PDF

    * [info] Executing: |open | https://vyvansefocus-b.erweb.eurorscg.com/ | |
    * [info] Executing: |assertTitle | Vyvanse® (lisdexamfetamine dimesylate) CII Patient Support | |
    * [info] Executing: |openWindow | http://www.vyvanse.com/pdf/prescribing_information.pdf | |
    * [info] Executing: |selectWindow | http://www.vyvanse.com/pdf/prescribing_information.pdf | |

    * [error] Could not find window with title http://www.vyvanse.com/pdf/prescribing_information.pdf

  6. Hello Ed!
    Sorry for replying so late. Instead of opening the pdf’s with ‘openWindow’, use Javascript to open the pdf’s with the ‘Window.open’ method, passing a window name, say ‘mywindow’. Assuming that link name is ‘pdf1′, the following should work.

    A example is posted here.

    http://www.codediesel.com/data/selenium/index.html

    Check the source to get the idea.

    The Selenium test case for the above link is here:

    http://www.codediesel.com/data/selenium/popup_testcase

    Note there will a 30 second delay after the ‘waitForPopUp’ command.

  7. Hi Sameer,

    The IDE does not play the recorded flow.Please help me in this regards.

    Thanks in advance.

Comments are closed.