我当时在做一个简单的基本程序,但是两天前我做同样的事情时,一切都很好,但是现在单击链接不起作用。我正在使用mozilla 23和selenium 2.45。这是我的程序

package basics;
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
public class first {
public static void main(String[] args) {
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.gmail.com");
driver.findElement(By.id("Email")).sendKeys("abcd");
driver.findElement(By.id("Passwd")).sendKeys("xxxx");
driver.findElement(By.id("SignIn")).click();
}
}


这是我得到的错误:

Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"SignIn"}
Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35'
System info: host: 'Arpita', ip: '100.98.209.144', os.name: 'Windows NT (unknown)', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_02'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/Arpitaa/AppData/Local/Temp/anonymous8522624877654328923webdriver-profile/extensions/[email protected]/components/driver-component.js:10271)
at <anonymous class>.FirefoxDriver.prototype.findElement(file:///C:/Users/Arpitaa/AppData/Local/Temp/anonymous8522624877654328923webdriver-profile/extensions/[email protected]/components/driver-component.js:10280)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Arpitaa/AppData/Local/Temp/anonymous8522624877654328923webdriver-profile/extensions/[email protected]/components/command-processor.js:12274)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/Arpitaa/AppData/Local/Temp/anonymous8522624877654328923webdriver-profile/extensions/[email protected]/components/command-processor.js:12279)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/Arpitaa/AppData/Local/Temp/anonymous8522624877654328923webdriver-profile/extensions/[email protected]/components/command-processor.js:12221)

最佳答案

它的登录名而不是登录名。尝试使用小写的“ s”。区分大小写对于在DOM中定位Web元素很重要。

10-07 23:34