Created
August 4, 2022 05:13
-
-
Save bharathmuddada/092905791576ba906a01a6e0c1dd2d84 to your computer and use it in GitHub Desktop.
Dropdown example with 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
| public class DropDownSample { | |
| public static void Main(string[] args) | |
| { | |
| new DriverManager().SetUpDriver(new ChromeConfig()); | |
| var driver = new ChromeDriver(); | |
| driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/dropdown"); | |
| driver.Manage().Window.Maximize(); | |
| var dropdownelement = driver.FindElement(By.Id("dropdown")); | |
| SelectElement se = new SelectElement(dropdownelement); | |
| se.SelectByIndex(1); | |
| se.SelectByText("Option 2"); | |
| se.SelectByValue("1"); | |
| var alloptions = se.Options; | |
| foreach (var option in alloptions) | |
| { | |
| Console.WriteLine(option.Text); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment