0

This should be such an incredibly simple solution but is turning into a mess. Just had a big angular upgrade (Angular 8) and now none of the dropdowns are selectable anymore for some reason. I used to be able to just do a SendKeys(Keys.Down) and iterate through all the options till I found mine but that doesn't work anymore.

After some searching I found the SelectElement method. Below is my implementation.

SelectElement dropdownSelect = new SelectElement(chromeDriver.FindElement(By.CssSelector("select[aria-describedby='myfield']")));

dropdownSelect.SelectByValue("option1");

The html looks like this

<select _ngcontent-teu-c24="" aria-describedby="myfield">
    <option _ngcontent-teu-c24="" disabled="" value="" ng-reflect-value="">Select</option>
    <option _ngcontent-teu-c24="" value="option1" ng-reflect-value="option1" class="ng-star-inserted">option1</option>
    <option _ngcontent-teu-c24="" value="option2" ng-reflect-value="option2" class="ng-star-inserted">option2</option>
</select>

Whenever I try to execute this code I get this error: "element not interactable: Element is not currently visible and may not be manipulated"

It's always visible on the page and it is clickable. I'm scratching my head here on how to solve this problem

JOO
  • 77
  • 8
  • Can you try this answer https://stackoverflow.com/a/51981698/7964299 to wait till the element is clickable ? – Naveen Nov 04 '19 at 19:36

2 Answers2

0

You can try clicking the dropdown first and then clicking the required option.

   chromeDriver.FindElement(By.CssSelector("select[aria-describedby='myfield']")).Click();
   chromeDriver.FindElement(By.Xpath("option[@value='option1']")).Click();
Amith YR
  • 172
  • 10
0

You need to wait for the element to be clickable. Most likely JavaScript is doing something and selenium is moving faster than JavaScript is executing.

var wait = new WebDriverWait(driver, 10);

wait.Until(d => ExpectedConditions.ElementIsClickable(By.CssSelector("select[aria-describedby='myfield']")));

dropdownSelect.SelectByValue("option1")
Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92