Text
Box Related Commnads
1.
type(locator, value) : example :
selenium.type("//input[@id='username']", "ganeshapv_2004");
2.
getValue(locator) : example : String username =
selenium.getAttribute("id=username");
3.
getAtttribute(locator) example : String nameAttr =
selenium.getAttribute("id=username");
4.
isEditable(locator)
if(selenium.isEditable("//input[@id='username']"))
{
System.out.println("Username
text field is Editable");
}else
{
System.out.println("Username
text field is non Editable");
}
Button
Related Commands
1.Click(locator)
example : selenium.click("//button[@id='.save']");
Label
Related Commands
1.
getText (loocator) example : String userLabel =
selenium.getText("//label[@for='username']");
Link
Related Commands
1.Click(Locator)
example : selenium.click("link=Forgot Password");
2.
getText(Locator) example String lnkTest =
selenium.getText(“link=Forgot Password”);
CheckBox/Radio
button Related Commands
1.check(Locator)
-- Checks the CheckBox example :
selenium.check("//input[@id='persistent']");
2.
uncheck(Locator) -- Unchecks the CheckBox example :
selenium.uncheck("//input[@id='persistent']");
3.
isChecked (Locator) -- Returns whether a checkbox is checked or
unchecked.
Returns
True, if a checkbox is checked.
Returns
False, if a checkbox is unchecked.
Example
: boolean checkStatus =
selenium.isChecked("//input[@id='persistent']");
System.out.println("Lnk
Test :"+checkStatus);
List
Box / Multi Select Related Commands
1.
getSelectOptions (Locator) -- Gets all the list items within a List
Box
example
: String[] options =
selenium.getSelectOptions("//select[@id='bm']");
for(int
i=0;i<options.length;i++)
{
System.out.println("options :"+options[i]);
}
2.
select (locator, valueToSelect) -- Selects an item in the List Box
example
: selenium.select("//select[@id='bm']", "August");
3.
getSelectedLabel (locator) -- Returns Selected Label
example
: String selectedValue =
selenium.getSelectedLabel("//select[@id='bm']");
System.out.println("selectedValue:"+
selectedValue);
4.
getSelectedIndex (locator) -- Gets option index (option number,
starting at 0) for selected option in the specified select element.
Example
: String selectedIndex =
selenium.getSelectedIndex("//select[@id='bm']");
System.out.println("selectedIndex
:"+selectedIndex);
5.
getSelectedValue(locator) -- Gets option value (value attribute)
for selected option in the specified select element.
Example
: String selectedVal =
selenium.getSelectedValue("//select[@id='bm']");
System.out.println("selectedVal :"+selectedVal);
6.
addSelection (locator,optionLocator) -- Add a selection to the set
of selected options in a multi- select element using an option
locator.
locator
- an element locator identifying a multi-select box
optionLocator - an option
locator (a label by default)
7.
removeSelection ( locator,optionLocator ) -- Remove a selection from
the set of selected options in a multi-select element using an option
locator.
locator
- an element locator identifying a multi-select box
optionLocator - an option
locator (a label by default)
8.
isSomethingSelected (locator) -- Returns whether a List Box is
selected or not.
Returns
True, if a List Box is selected.
Returns
False, if a List Box is not selected.
Example
: boolean elementSelected =
selenium.isSomethingSelected("//select[@id='bm']");
System.out.println("elementSelected
:"+elementSelected);
Text
Related Commands
1.
isText Present(pattern)
a.
Return true if the text is present
b.
You can give regular expression with test (Note: It supports glob
pattern)
Examples
boolean
textAvailabel = selenium.isTextPresent("Find a Partner");
System.out.println("text
availability :"+textAvailabel);
boolean
textAvailabel1 = selenium.isTextPresent("Find a Partner");
System.out.println("text
availability :"+textAvailabel1);
boolean
textAvailabel2 = selenium.isTextPresent("Find a *");
System.out.println("text
availability :"+textAvailabel2);
boolean
textAvailabel3 = selenium.isTextPresent("Find a *");
System.out.println("text
availability :"+textAvailabel3);
boolean
textAvailabel4 = selenium.isTextPresent("Find a ?art*");
System.out.println("text
availability :"+textAvailabel4);
very useful
ReplyDeletehelp full............
ReplyDelete