Last active
September 15, 2022 08:14
-
-
Save SarahElson/4223bb3d5f2970284a2b9850f76cf846 to your computer and use it in GitHub Desktop.
How To Select Dropdown In Selenium C#?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
[TestCase("Monday")] | |
[TestCase("Tuesday")] | |
[TestCase("Wednesday")] | |
[TestCase("Thursday")] | |
[TestCase("Friday")] | |
[TestCase("Saturday")] | |
[TestCase("Sunday")] | |
[Parallelizable(ParallelScope.All)] | |
public void ValidateDropDownSelection(string dayOfTheWeek) | |
{ driver.Navigate().GoToUrl("https://www.lambdatest.com/selenium-playground/select-dropdown-demo"); | |
SelectElement dropDown = new SelectElement(driver.FindElement(By.Id("select-demo"))); | |
dropDown.SelectByValue(dayOfTheWeek); | |
string actualText = driver.FindElement(By.CssSelector(".selected-value.text-size-14")).Text; | |
Assert.True(actualText.Contains(dayOfTheWeek), $"The expected day of the week {dayOfTheWeek} was not selected. The actual text was: {actualText}."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment