- Oct 26, 2018
- admin
- 0
Handling SelectBox In Selenium
[Test]
public void HandlingSelectBox()
{
IWebDriver dr = new ChromeDriver();
dr.Navigate().GoToUrl("https://demo.guru99.com/test/newtours/register.php");
IWebElement ddCountry = dr.FindElement(By.Name("country"));
SelectElement objSelect = new SelectElement(ddCountry);
objSelect.SelectByIndex(2);
objSelect.SelectByText("INDIA");
objSelect.SelectByValue("CHINA");
Console.WriteLine("Multiple values allowed:" + objSelect.IsMultiple);
int optCount = objSelect.Options.Count;
Console.WriteLine("options count is:" + optCount);
//objSelect.DeselectByValue("CHINA");
for (int i = 0; i < optCount; i++)
{
objSelect.SelectByIndex(i);
}
}
Tags: Handling Selectbox, Interacting with SelectBox in Selenium, Selenium Training in Hyderabad, Selenium Tutorial
