2

I'm using the Selenium 2.0 web drivers to try and login to a page. The following code works with the Firefox webdriver just fine, it finds the fields, fills them in and clicks the button.

driver.FindElement(By.Id("UserName")).SendKeys("name"); 
driver.FindElement(By.Id("Password")).SendKeys("test");
driver.FindElement(By.Id("btnLogin")).Click();

However, whenever I try to use the internet explorer webdriver it says it is unable to find the element with id == UserName. I tried using By.Name, and By.Xpath as well with valid inputs but I still get the same error saying it can't find the element. I am using IE 9 so I'm aware it may be a compatibility issue, however I can't seem to find any posts or information saying there is a known issue.

I just wanted to see if anyone else was experiencing the same issue, or if there is something I'm not doing correctly that is causing my issue. Also, this is a C# .NET project.

-- Edit --

Apparently it is an issue with IE9, I removed 9 and went back to 8 and the test works. I'm still interested to know if anyone finds out why this happens or if there is a work around.

Russell Durham
  • 624
  • 6
  • 18

2 Answers2

2

The current release of Selenium (2.0b2) does not support IE9, however 2.0b3 should be released soon and supports both IE9 and Firefox 4.

Dave Hunt
  • 8,191
  • 4
  • 38
  • 39
  • 1
    2.0b3 has been released today with support for IE9 and Firefox 4: http://seleniumhq.wordpress.com/2011/03/21/selenium-2-0b3-the-next-gen-browser-release/ – Dave Hunt Mar 21 '11 at 21:25
0

This answer may also be relevant for anyone experiencing issues getting 'clicks' to fire with IE9.

A workaround to this is to send a .Click() to another element on the page, so that the browser gets the focus, before attempting to click the link, e.g. it's parent:

driver.FindElement(By.Id("Logout")).FindElement(By.XPath("..")).Click();
driver.FindElement(By.Id("Logout")).Click();
Community
  • 1
  • 1
Peter Bernier
  • 8,038
  • 6
  • 38
  • 53