Reputation: 2640
I'm working on writing a selenium script, where i need to select the list box which gets populated once i enter the text in the textbox. But i'm not able to the select the listbox item with the below peice of code,
webDriver.FindElement(By.Name("hiringManager")).SendKeys(ExcelLibrary.ReadData(1, "HiringManager"));
Thread.Sleep(3000);
SelectElement selectHiringManager = new SelectElement(webDriver.FindElement(By.Name("hiringManagerIds")));
selectHiringManager.SelectByText(ExcelLibrary.ReadData(1, "HiringManager"));
Please let me know how do i select the listbox item
Upvotes: 0
Views: 861
Reputation: 2640
I was able to fix this issue with the below code,
webDriver.FindElement(By.Name("hiringManager")).SendKeys(ExcelLibrary.ReadData(1, "HiringManager"));
Thread.Sleep(1000);
webDriver.FindElement(By.CssSelector("select[name=hiringManagerIds] option:nth-child(1)")).Click();
Upvotes: 1