Searching...
Sunday 30 December 2012

Handling DropDowns in Selenium RC

Handling DropDowns in Selenium RC

We can handle Drop Downs in 2 ways in Selenium RC

1. Gets all the list items within a List Box using getSelectOptions (Locator)
String[] options = selenium.getSelectOptions("//select[@id='bm']");
for(int i=0;i<options.length;i++)
{
System.out.println("options :"+options[i]);
}


2. Using getXpathCount(Xpath)
int Num=selenium.getXpathcount("//*[@name='test']/options").intvalue();
String Str;
For(i=0; i<=Num; i++)
{
Str=selenium.getText("//*[@name='test']/options["+i+"]");
System.out.println(Str);
}



0 comments:

Post a Comment

 
Back to top!