开发者

Selenium 2.0 & IE9

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'开发者_如何学Pythonm still interested to know if anyone finds out why this happens or if there is a work around.


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.


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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜