【发布时间】:2011-07-31 07:04:58
【问题描述】:
在使用IE9的IE驱动时,有时Click方法只会选择一个按钮,它不会做Click()的动作。请注意,这只是偶尔发生,所以我认为问题不是代码。在 Firefox4 中使用 Firefox 驱动程序没有问题。我也遇到了偶尔也找不到元素的问题,但只是在 IE 中,而不是在 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();
}
我见过类似的问题 (http://stackoverflow.com/questions/4737205/selenium-webdriver-ie-button-issue),但我没有动态生成的 id。
【问题讨论】:
标签: internet-explorer-9 webdriver selenium-webdriver