When using the IE driver with IE9, occasionally the Click method will only select a button, it wont do the action of the Click(). Note this only happens occasionally, so i don't think it is the code that is the problem. Using the Firefox driver with Firefox4 has no problems. I am also having an issue where elements are not being found occasionally too, but only in IE again, not Firefox.
if (Driver.FindElement(By.Name("username")) == null) {
//sometimes gets here in IE, never gets here in Firefox
}
Driver.FindElement(By.Name("username")).SendKeys(username);
Driver.FindElement(By.Name("surname")).SendKeys(surname);
Driver.FindElement(By.Name("firstname")).SendKeys(firstname);
string url = Driver.Url;
Driver.FindElement(By.Name("cmd")).Click();
if (Driver.Url == url) {
//if the page didnt change, click the link again
Driver.FindElement(By.Name("cmd")).Click();
}
I have seen this similar questions (http://stackoverflow.com/questions/4737205/selenium-webdriver-ie-button-issue), but i do not have dynamicly generated ids.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…