Friday, March 9, 2012

Working with Selenium IDE And RC



Required  Firefox Addons for selenium 

Step 1:à selenium IDE
Step 2:à Xpather
Step 3:à Firebug
 Once u done with this

Creating Sample Test case using Selenium  Ide

Go to Mozilla Firefox browser àToolsà selenium Ide

Open selenium IDE and it looks like this



Go to application and right click on the object to open Xpather



In Mozilla Firefox browser se at the right most bottom to your hand to find firebug 



Note: The selenium IDE will work only on Mozilla Firefox browser

For example:
Open Browser and URL as www.newrtours.demoaut.com
Here we have a sample test case for login form.
Go to Tools and open selenium IDE find the path for the action we need to perform.
As shown below

For username




Here ”click “  command to perform action.
This step is the target where to perform an action “//form[@name='home']//input[@name='userName']”
This step tell what is the value need for the particular action “test”
And same  steps as above







login
store
test
UserName
echo
Username is ${UserName}

type
//form[@name='home']//input[@name='userName']
${UserName}
type
//form[@name='home']//input[@name='password']
${UserName}
click
//form[@name='home']//input[@name='login']

waitForElementPresent
//form[@name='findflight']//input[@name='findFlights']

verifyElementPresent
//form[@name='findflight']//input[@name='findFlights']

click
//form[@name='findflight']//input[@name='tripType'][@value='oneway']

select
//form[@name='findflight']//select[@name='passCount']
2
select
//form[@name='findflight']//select[@name='fromPort']
Frankfurt
select
//form[@name='findflight']//select[@name='fromMonth']
April
select
//form[@name='findflight']//select[@name='fromDay']
1
select
//form[@name='findflight']//select[@name='toPort']
Paris
select
//form[@name='findflight']//select[@name='toMonth']
June
select
//form[@name='findflight']//select[@name='toDay']
7
click
//form[@name='findflight']//input[@name='servClass'][@value='First']

select
//form[@name='findflight']//select[@name='airline']
Blue Skies Airlines
click
//form[@name='findflight']//input[@name='findFlights']

waitForElementPresent
//img[contains(@src,'mast_selectflight')]

click
//form[@name='results']//input[@name='outFlight'][@value='Pangea Airlines$362$274$9:17']

click
//form[@name='results']//input[@name='inFlight'][@value='Pangea Airlines$632$282$16:37']

click
//form[@name='results']//input[@name='reserveFlights']

waitForElementPresent
//img[contains(@src,'mast_book')]


store(expression, variableName)

Arguments:
  • expression - the value to store
  • variableName - the name of a variable in which the result is to be stored.
This command is a synonym for storeExpression


echo(message)
Arguments:
  • message - the message to print
Prints the specified message into the third table cell in your Selenese tables. Useful for debugging.


type(locator, value)
Arguments:
Sets the value of an input field, as though you typed it in. Can also be used to set the value of combo boxes, check boxes, etc. In these cases, value should be the value of the option selected, not the visible text.
click(locator)
Arguments:
  • locator - an element locator
Clicks on a link, button, checkbox or radio button. If the click action causes a new page to load (like a link usually does), call waitForPageToLoad.
waitForElementPresent(locator)
Generated from isElementPresent(locator)
Arguments:
Returns:
true if the element is present, false otherwise
Verifies that the specified element is somewhere on the page.

verifyElementPresent(locator)
Generated from isElementPresent(locator)
Arguments:
Returns:
true if the element is present, false otherwise
Verifies that the specified element is somewhere on the page.

select(selectLocator, optionLocator)
Arguments:
  • selectLocator - an element locator identifying a drop-down menu
  • optionLocator - an option locator (a label by default)
Select an option from a drop-down using an option locator. Option locators provide different ways of specifying options of an HTML Select element (e.g. for selecting a specific option, or for asserting that the selected option satisfies a specification). There are several forms of Select Option Locator.
  • label=labelPattern: matches options based on their labels, i.e. the visible text. (This is the default.)
    • label=regexp:^[Oo]ther
  • value=valuePattern: matches options based on their values.
    • value=other
  • id=id: matches options based on their ids.
    • id=option1
  • index=index: matches an option based on its index (offset from zero).
    • index=2
If no option locator prefix is provided, the default behaviour is to match on label


No comments:

Post a Comment