Using selenium.GetSelectedIndex in Webdriver 

Here is the Selenium RC code for selenium.GetSelectedIndex in Webdriver. This code is in Visual Studio C#

public string GetSelectedIndex(string xpath)
{
string text="";
int statenum = Convert.ToInt32(GetXpathCount(xpath+"/option"));
for (int i = 1; i < statenum; i++)
{
if (IsElementPresent(xpath+"/option[" + i + "][@selected]"))
{
text = Convert.ToString((i - 1));
}
}
return text;
}


Author: Pavandeep Puddupakkam on December 14, 2011
Category: WebDriver
Tags: , ,
Selenium Webdriver Forum -The Online Community for Selenium Webdriver and Selenium RC Users and Professionals

Leave a Reply

Last articles