点击链接无法在selenium webdriver 2.45.0中运行

时间:2015-04-15 06:11:46

标签: java selenium eclipse-luna

我正在做一个简单的基本程序但是当我做了相同的2天回来,一切都工作正常,但现在点击链接不起作用..我正在使用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/fxdriver@googlecode.com/components/driver-component.js:10271)
at <anonymous class>.FirefoxDriver.prototype.findElement(file:///C:/Users/Arpitaa/AppData/Local/Temp/anonymous8522624877654328923webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10280)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Arpitaa/AppData/Local/Temp/anonymous8522624877654328923webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12274)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/Arpitaa/AppData/Local/Temp/anonymous8522624877654328923webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12279)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/Arpitaa/AppData/Local/Temp/anonymous8522624877654328923webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12221)

1 个答案:

答案 0 :(得分:1)

signIn 而非 登录 。尝试使用小写字母&#39;。区分大小写对于在DOM中定位Web元素很重要。