Reputation: 12816
I'm using the following code in C# to select a value in a dropdown list:
new SelectElement(driver.FindElement(By.Name("element"))).SelectByIndex(2);
This works with Firefox and IE8 but not with Chrome, nothing gets selected. Are there any know issues with SelectElement? Any alternatives to get it to work in Chrome?
I'm using the standalone server 2.0rc3 and Chrome 12
Upvotes: 2
Views: 2714
Reputation: 12816
For anyone else having this problem, I solved it by clicking on the element and sending the keys to select the value, so something like:
driver.FindElement(By.Name("element")).Click();
driver.FindElement(By.Name("element")).SendKeys("some value");
Upvotes: 2
Reputation: 27496
This is a known issue with the Chrome driver. The IWebElement.Select() and .Toggle() methods were deprecated in 2.0RC3, requiring you to use .Click() instead. The SelectElement support class was updated to handle this change; however, the ChromeDriver.exe (which is built and provide by the Chromium team) has yet to catch up. So using IWebElement.Click() on an element doesn't yet work in Chrome.
Upvotes: 1