0

I am trying to select and click an option within a dropdown using C# code with Selenium Webdriver and Nunit Framework. I wrote the following code:

 IWebElement dropdown = Driver.FindElement(By.XPath("//*[@id='lane_id']"));
 new SelectElement(dropdown).SelectByText("All Lanes");
 dropdown.Click();

Now I know that dropdown.click() is wrong as it does not have the XPath for the selected option. But I want to somehow click the selected option.

P.S: Apologies for any mistake / community violations, this is my first ever query on stackoverflow.

  • Does this answer your question? [Selenium Select - Selecting dropdown option by part of the text](https://stackoverflow.com/questions/29772075/selenium-select-selecting-dropdown-option-by-part-of-the-text) – Ryan Wilson Nov 13 '20 at 13:20
  • 1
    What error are you getting? – Jortega Nov 13 '20 at 13:48
  • 1
    `Select` automatically choose the option for you. You don't need to click on option. – KunLun Nov 13 '20 at 14:06

0 Answers0