Thursday, December 16, 2010

Selenium IDE Useful Commands

Selenium IDE is an integrated development environment for Selenium scripts. It is implemented as a Firefox extension.
Selenium IDE allows you to record, edit, and debug tests. 


Selenium IDE can be downloaded from http://seleniumhq.org/download/ 

Recording any action on a page will be done using commands known as Selenese Commands.

Most common Commands used as follows:

verifyTextPresent  
      Verifies that text appears on the page.  It can be dynamic text that was loaded with ajax.  If it’s on the page in the active window at the time this command is called, it’ll find it.

verifyValue
          Verifies the value of an input field.  Provide the id of the input as the target and the value is the text you’re expecting.

click 
         Tells the test to click something on the page.  The target can be referenced with the element ID or xPath as with the other commands.

clickAndWait
      This command is useful for form submissions.  Many times when you’re in record mode and click a submit button, selenium will only record a “click” command.  This will break your test commands following the form submission where you verify the presence of a success message or form values because the next page hasn’t loaded yet.  The “wait” portion will wait to continue the testing when the next page has fully loaded. 

select
      select an option in a select box by providing the id of the select box and the option value.
   
verifyAttribute
           Useful for checking the attributes (attributes such as class, style, href and anchor tags)   for specific url.
           To verifyAttribute first thing you need to do is viewXpath by right clicking on particular attribute.

            Xpath catcher is an add-on for firefox to viewXpath. You can download Xpath catcher from https://addons.mozilla.org/en-US/firefox/addon/1095/?id=1095 


Steps to find Xpath
        1.Right click on attribute and select viewXpath 
        2.Copy the Xpath in target field of the Selenium IDE
        3.Edit the xpath copied as follows
                     For example you have xpath as  id('p_13872472-main_story')/x:div/x:div/x:h3/x:a
                    You have to edit in the following manner for verifying class attribute
                     //div[@id='p_13872472-main_story']/div/div/h3/a/@class




         

       



1 comment: