Selenium IDE


 Selenium IDE
Selenium is a test tool for web applications. Selenium tests run directly in a browser, just as real users do. Selenium is a JavaScript framework that runs in your web browser. Selenium IDE is a FireFox extension made by the OpenQA.org team, that records mouse and keyboard actions as Selenium commands. It is very easy to use and powerful tool for controlling, automating or testing web sites. You can record how an application is being used and then play back those recordings followed by asserts. After recording, you can export test case in many languages like java, Ruby, Perl, python etc.

So, let’s get started with it.

Installing Selenium:  IDE is only available for Firefox as a add-on. In Firefox browser, go to Tools, add-ons, click on get Add-ons, search for Selenium IDE, Click on Install IDE .After installing, restart FireFox.


Selenium IDE explained

After installing Selenium IDE, go to Tools->Selenium IDE, you’ll get a screen which contains

Base URL:The root of web application you want to test. It can be any website URL under test. For ex, If you are test Google’s homepage, then Base URL will be automatically filled by www.google.co.in.

Fast and Slow: We can specify the speed of the test case using Fast and Slow. Default is fast. Sometimes test fails due to the fast execution. Selenium IDE gives the facility to adjust the speed.

Run Test Suite: If there are many test cases, we can put all together in a suite. This button helps us to run the entire suite.

Run a single Test: After recording a test case, we can run the test case by clicking on this button.

Pause: We can pause a test case using this button.

Step: We can step through the test case.

Apply RoleUp Roles:

Record By default when the IDE comes up it has recording turned on.  You might want to turn it off by clicking on the red button, until you are ready to begin recording.

Command ,Target, Value: Specify commands, including asserts.

Log, Reference, UI-Element, RollUp: Reference of the currently selected command.

Recording a Simple Test:
  1.  Start Selenium IDE  in Firefox: Tools->Selenium IDE.
  2. Browse to Google.com and enter ’selenium’ in the search box and click enter.
  3. Click on the first result, which is that of selenium.openqa.org.
  4. Stop the recording by clicking on the record button.
  5. If you click on the ‘Source’ tab you can see the test html generated by selenium.
  6. The ‘table’ tab shows the commands recorded by Selenium.  Open a new tab in Firefox and click on the Selenium IDE’s play button to run the recorded test
                         
There are several commands that can be used  .To use the available commands ,follow the step below.
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 ‘mpower’ and run the test again. Now the test fails and you should get the screen below.

We can record and play on any website.
    
Second  example: Now we are  going to use few more commands in our test case. Follow the Step by Step procedure.
  1. Open Firefox browser
  2. In the navigation bar, type in http://www.mpowerglobal.com/
  3. Go to Tools->Selenium IDE. By default it starts recording.
  4. Now go back to firefox, on the http://www.mpowerglobal.com/ home page, On right clicking anywhere on the page ,you can find show all commands with an arrow.On following the arrow,you can find assertTitle  IT Business Consulting | Liferay Portal | … command. select that command.
  5. Now highlight “Who we Are” and right click , select  verifyTextPresent.   
  6. Now go to Selenium IDE , you can find all the actions you performed in command table tab.      
  7. Now go to File->Save TestCase.Browse to the folder you want to save and then save test case  in .html format.

We have successfully created another test case.Now if we want to run these two test cases one after the other, then we can put them in a suite.


Writing a Test Suite: A Test Suite in Selenium is just an HTML file that contains a table of links to tests.

<html>
<table border="1" style="font-size:25">
    <tr><td><a href="./F:/Tests in html/testcase1">Google test</a></td></tr>
                        <tr><td><a href="./F:/Tests in html/testcase2">mPower test</a></td></tr>
</table>
</html>

In order to create a test suite, all you have to do is create an HTML document that is composed of a table of links to your individual unit tests. Obviously you’ll need to adjust the href’s to wherever you have your test cases stored, but essentially that is all there is to creating a test suite.

Running the Test Suite:   After creating the suite, go to Selenium IDE ->File-> Open test suite->navigate to your main suite position.

After opening suite , click on run test suite and see your tests working. To view the test case running, minimize the FireFox window and keep selenium IDE next to it.
  
After recording, we can export test case in many languages .Java developers can export test case in Java. Just have to go File->Export test case as->Java (JUnit)
                           
After exporting, we need Selenium RC to run our exported test case.

Extensions to Selenium IDE: You can extend functionalities of Selenium IDE with JavaScript. There are 2 types of scripts in Selenium IDE - formats and extensions.
User-extensions are very easy to use with the selenium IDE.
  1. Create your user extension and save it as user-extensions.js.
  2. Open Firefox and open Selenium-IDE.Click on Tools, Options
  3. Write the user extensions.js file.
  4. Your user-extension will not yet be loaded, you must close and restart Selenium-IDE.
  5. Now you can use the values present in user-extensions.js file.
XPath: One of the main reasons for using XPath is when you don’t have a suitable id or name attribute for the element you wish to locate. You can use XPath to either locate the element in absolute terms (not advised), or relative to an element that does have an id or name attribute. XPath locators can also be used to specify elements via attributes other than id and name.
There are also a couple of very useful Firefox Add-ons that can assist in discovering the XPath of an element:
  • XPath Checker - suggests XPath and can be used to test XPath results.
  • Firebug - XPath suggestions are just one of the many powerful features of this very useful add-on.

38 comments:

  1. Hi,
    I am new to Selenium tool, Actually we have developed the application on Java and Flex. We want to use selenium tool.
    Please let me know how to install selenium with flex.

    Thanks,
    Raman

    ReplyDelete
    Replies
    1. IntelliMindz is the best IT Training in Bangalore with placement, offering 200 and more software courses with 100% Placement Assistance.

      Selenium Training In Bangalore

      Manual Testing Training In Tirupur

      Delete
  2. Hi,

    You can use selenium rc and java to test your application.There is nothing like selenium +flex installation. Just download Selenium RC and write the test script.
    You can also test using IDE.What problem you are facing while recording script in IDE,let me know.

    ReplyDelete
  3. How to find the name and handle the pop up windows that come automatically(dynamic popups)
    for example : if a pop up window comes immediately after login.

    ReplyDelete
  4. Use waitforpopup command to handle that pop up

    ReplyDelete
  5. Hi... I am automating a test framework. I have a challenge to save the exported documents from the UI. I have a link 'Export as xls' in the UI. So, if i click 'Export as xls' in the UI, immediately, a windows xp pop up will arise which asks us to save or open the document. How to automate this exporting and saving or opening the documents.. Thanks in advance if any one can help me

    ReplyDelete
  6. Hi... I am automating a test framework. I have a challenge to save the exported documents from the UI. I have a link 'Export as xls' in the UI. So, if i click 'Export as xls' in the UI, immediately, a windows xp pop up will arise which asks us to save or open the document. How to automate this exporting and saving or opening the documents.. Thanks in advance if any one can help me

    ReplyDelete
    Replies
    1. You can solve this problem by using firefox profile. when the downloads popup appears for the first time, click on checkbox ,"do this for all " which appears below open file, save file radio button.Then, next time, downloads window won't open, and hence file gets stored on local.

      Delete
  7. I am working on selenium RC, but getting error while executing script
    In IE and firefox - i am getting message that


    - 14:26:08.830 INFO - Killing Firefox...
    14:26:08.832 WARN - Firefox seems to have ended on its own (did we kill the real
    browser???)


    And for iexploreproxy
    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
    Timestamp: Tue, 7 Feb 2012 08:55:05 UTC
    Message: Access is denied.
    Line: 184
    Char: 9
    Code: 0
    URI: http://www.google.com/selenium-server/core/scripts/selenium-testrunner.js

    ReplyDelete
  8. Nice information about the Selenium IDE and the options in Selenium IDE are explained in an understandable manner my sincere thanks for sharing this post
    Selenium Training in Chennai

    ReplyDelete
  9. you do such a great thing. I read your blog completely. i understand your writing manner. Thanks for sharing.


    selenium Training in Bangalore

    ReplyDelete
  10. It’s too informative blog and I am getting conglomerations of info’s about Software certification. Thanks for sharing...
    Software Testing Training in Bangalore

    ReplyDelete
  11. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.

    selenium training in bangalore|

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Thanks For Posting. Can you please Add Some More Selenium IDE Tutorials In your Blog Posts.

    ReplyDelete

  14. Best Solidworks training institute in noida

    SolidWorks is a solid modeling computer-aided design (CAD) and computer-aided engineering (CAE) computer program that runs on Microsoft Windows. SolidWorks is published by Dassault Systems. Solid Works: well, it is purely a product to design machines. But, of course, there are other applications, like aerospace, automobile, consumer products, etc. Much user friendly than the former one, in terms of modeling, editing designs, creating mechanisms, etc.
    Solid Works is a Middle level, Main stream software with focus on Product development & this software is aimed at Small scale & Middle level Companies whose interest is to have a reasonably priced CAD system which can support their product development needs and at the same time helps them get their product market faster.

    Company Address:
    WEBTRACKKER TECHNOLOGY (P) LTD.
    C-67,Sector-63,Noida,India.
    E-mail: info@webtracker.com
    Phone No: 0120-4330760 ,+91-880-282-0025

    webtrackker.com/solidworks-training-Course-institute-in-noida-delhi

    ReplyDelete
  15. 3D Animation Training in Noida

    Best institute for 3d Animation and Multimedia

    Best institute for 3d Animation Course training Classes in Noida- webtrackker Is providing the 3d Animation and Multimedia training in noida with 100% placement supports. for more call - 8802820025.

    3D Animation Training in Noida

    Company Address:

    Webtrackker Technology

    C- 67, Sector- 63, Noida

    Phone: 01204330760, 8802820025

    Email: info@webtrackker.com

    Website: http://webtrackker.com/Best-institute-3dAnimation-Multimedia-Course-training-Classes-in-Noida.php

    ReplyDelete
  16. Latest News in Hindi

    Latest News in Hindi- Hindustan channel is the best online web portal in india where you read the all latest indian news in hindi. if you are looking the Latest News in Hindi, live news channel, hindi news channel, live news channels in hindi, live hindi channels then hindustan channel is best for you.
    Latest News in Hindi

    Company address:
    C- 67, Sector- 63, Noida
    Phone: 01204330760, 8802820025


    URL: https://hindustanchannel.com

    ReplyDelete
  17. it’s really nice and meanful. it’s really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull information.
    it is very Useful to Selenium Beginners
    Hadoop Training in Hyderabad
    Selenium Online Training in Hyderabad
    Tableau Online Training in Hyderabad

    ReplyDelete
  18. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information.
    Selenium Training in Gurgaon 

    ReplyDelete
  19. Thanks for sharing The Information The Information shared is very valuable Please keep Updating us Time Just went on redaing the article Python Online Training AWS Online Training Devops Online Training Data Science Online Training

    ReplyDelete
  20. It is very good and very informative. There is a useful information in it.Thanks for posting... DevOps Training In Hyderabad

    ReplyDelete
  21. Thanks for sharing great info with us.

    I wanted to write a little comment to support you and wish you a good continuation All the best for all your blogging efforts.Your good knowledge and kindness in playing with all the pieces were very useful.
    Python classes in Pune

    ReplyDelete
  22. This is most informative and also this post most user friendly and super navigation to all posts. Thank you so much for giving this information to me.selenium training in bangalore




    ReplyDelete
  23. It was really a wonderful article and I was really impressed by reading this blog. We are giving all software Courses such as Data science, big data, hadoop, R programming, python and many other course. Data science training institute in bangalore is one of the reputed training institute in bangalore. They give professional and real time training for all students.

    ReplyDelete
  24. SSbizconsulting is one of the best firm of IT consulting and project management services that operate across Sydney, Australia. Our key strength is focusing on our client’s needs such as implementing project management HR, Payroll and Workforce Management Systems. Our in-depth knowledge in the industry allows us to provide our clients with insights that add real value.

    ReplyDelete
  25. Getting into Integrated Marketing is tough if you don’t have thorough knowledge. Then why not join Talentedge, the first ed-tech platform that has joined hands with XLRI and MICA to provide the best courses to the students.

    ReplyDelete
  26. Visit Bharat Go Digital Academy to learn the digital marketing skills in India.

    ReplyDelete
  27. If You Are Looking For Forex Broker? Read This Review And Find Out How Much I've Enjoyed My Experience With BITFINEX

    ReplyDelete
  28. There Are Many Complaints About XM REVIEW Broker In The Internet But You Should Read This Review Before Investing Your Money With Them. We Have Personally Tested XM Fx And Found It To Be A Scam, Avoid Them At All Costs!

    ReplyDelete