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;
}


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>