我正在做一个简单的基本程序,但是当我两天前做同样的程序时,一切都很好,但是现在点击链接不起作用。我使用的是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)发布于 2015-04-15 14:25:04
它是signIn而不是SignIn。请尝试使用小写的“%s”。在DOM中定位web元素时需要区分大小写。
https://stackoverflow.com/questions/29642747
复制相似问题