Last active
September 15, 2022 08:15
-
-
Save SarahElson/737445a56795860f142bdbdb0bb7451e 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] | |
public void ValidateMultipleSelection() | |
{ | |
driver.Navigate().GoToUrl("https://www.lambdatest.com/selenium-playground/select-dropdown-demo"); | |
string[] selectedStates = { "Florida", "New York", "Texas" }; | |
var multiSelect = new SelectElement(driver.FindElement(By.Id("multi-select"))); | |
Assert.IsTrue(multiSelect.IsMultiple, "The Select does not allow multiple selection."); | |
foreach (var state in selectedStates) | |
{ | |
multiSelect.SelectByText(state); | |
} | |
multiSelect.DeselectAll(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment