Selenium IDE

Selenium IDE:
  • Selenium IDE is very useful if you want to quickly create scripts to test your web application.
  • It provides an easy interface for developing/Running/Debugging test scripts or test suites
  • It is a Firefox add-on
  • It provides Record & Playback functionality
  • It can only run scripts on Firefox and it’s not available for other browsers
  • You can export recorded tests in multiple languages to use with Selenium WebDriver
It consists of mainly 4 parts:
  1. Menu bar
  2. Tool bar
  3. Test case pane
  4. Log, reference, etc

Selenium IDE User Interface
 Figure 1: Selenium IDE User Interface











Selenium IDE consists of 4 types of commands:
  1. type, click, sendkeys, select, check, typeAndWait, clickAndWait, selectAndWait
  2. assertTitle, assertText, assertElementPresent, assertAttribute
  3. verifyTitle, verifyText, verifyElementPresent, verifyAttribute
  4. waitForTitle, waitForText, waitForPageToLoad, waitForAttribute

    Locating web elements on any page with the help of Selenium IDE:
    1. identifier
    2. Using id attribute
    3. Using name attribute
    4. xpath
    5. css
    6. link
    7. dom (Document Object Model)
    XPATH:
    • xpath=//tagName[@attribute='value']
    • xpath=//*[@attribute='value']
    • xpath=//tagName[@attribute1='value1' and @attribute2='value2']
    • xpath=//tagName[@attribute1='value1' or @attribute2='value2']
    • xpath=//tagName[text()='value1']
    • xpath=//tagName[contains(@attribute, 'value1')]
    • xpath=//tagName[starts-with(@attribute, 'value1')]
    • xpath=//tagName[ends-with(@attribute, 'value1')]
    • xpath=//tagName[@attribute='value']/childTag/GrandChildTag
    • xpath=//tagName[index]      index value is 1, 2, 3, 4, ...
    CSS:
    •  css=#idvalue
    •  css=.className 
    •  css=tagName#idvalue
    •  css=tagName.className
    •  css=tagName[attribute='value']
    •  css=tagName[attribute1='value1'][attribute2='value2']
    •  css=tagName[attribute*='value1')]    like contains
    •  css=tagName[attribute^='value1')]    like starts-with
    •  css=tagName[attribute$='value1')]    like ends-with
    •  css=tagName[attribute='value']/childTag/GrandChildTag


    Google Search Test Case:
    open /?gws_rd=ssl
    type id=lst-ib selenium
    click name=btnG
    waitForTitle selenium - Google Search
    clickAndWait link=Selenium - Web Browser Automation
    assertTitle Selenium - Web Browser Automation
    verifyText link=Download Download

    SlideShareLogin
    open http://www.slideshare.net/
    click id=login
    waitForValue id=user_login
    type css=#user_login username
    type xpath=//input[@id='user_password'] password
    clickAndWait login_from_loginpage
    waitForTitle Share and Discover Knowledge on LinkedIn SlideShare
    verifyTitle Share and Discover Knowledge on LinkedIn SlideShare

    UploadFileSlideShare
    open /
    clickAndWait link=Upload
    type name=file C:\Users\sysadm\Desktop\abc.docx
    waitForAttribute id=img_slide_image@id img_slide_image
    type name=title Simple File
    type //textarea[@name='description'] Sample Doc File
    select name=top_cat label=Education
    clickAndWait xpath=(//button[@type='submit'])[2]
    waitForTitle Simple File
    assertTitle Simple File

    DeleteUploadedFile
    open /
    clickAndWait link=Upload
    clickAndWait link=My Uploads
    waitForElementPresent //input[contains(@id,'heck-')]
    check //input[starts-with(@id,'check-')]
    click id=j-delete-common
    waitForText //div[@id='main-container']/div[2]/div/span You do not have any uploads.
    verifyText link=Upload one now Upload one now

    SideshareLogout
    open /
    clickAndWait link=Upload
    clickAndWait link=Logout
    verifyTitle Share and Discover Knowledge on LinkedIn SlideShare
    verifyText id=login Login

        1 comment: