2

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

2
  • Would you be able to perform the find By.Id() instead? I found the Firefox driver seems to be the most stable, and Chrome tends to have these occasional inconsistencies (perhaps exacerbated by their constant updates?) Commented Jun 30, 2011 at 18:44
  • the element only has a name, I tried XPath instead and still no dice Commented Jun 30, 2011 at 20:07

2 Answers 2

2

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");
Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

This has been fixed in the 7/7/2011 release of chrome driver, hurray! code.google.com/p/chromium/downloads/list

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.