请问这个登录脚本错哪了?确实是定位问题吗?该怎么解决?
-----------------------------------------脚本----------------------------------------------------------------------------------------public class day05 {
WebDriver driver;
public void startFire(){
System.setProperty("webdriver.firefox.bin", "C:\\Z_firefox_browser_32_0_3\\firefox.exe");
driver=new FirefoxDriver();
}
public void goTo(){
driver.navigate().to("http://192.168.1.110:8888/fsasit");
}
public void testInput(){
driver.findElement(By.id("loginname")).sendKeys("admin");
driver.findElement(By.xpath(".//*[@id='password']")).sendKeys("1");
}
public void testButton(){
WebElement element=driver.findElement(By.name("Image10"));
if(element.isEnabled()){
element.click();
}
}
public static void main(String[] args) {
day05 d=new day05();
d.startFire();
d.goTo();
d.testInput();
d.testButton();
}
}
---------------------------------------------------------------报错---------------------------------------------------------------------------------------------------------------
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"loginname"}
Command duration or timeout: 1.11 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'asit-f226940e7c', ip: '192.168.1.128', os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27'
*** Element info: {Using=id, value=loginname}
Session ID: 276583ff-0f65-49ec-b8a1-958afb617151
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=32.0.3, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:393)
at org.openqa.selenium.By$ById.findElement(By.java:214)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at com.woo.www.day05.testInput(day05.java:29)
at com.woo.www.day05.main(day05.java:50)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"loginname"}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'asit-f226940e7c', ip: '192.168.1.128', os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/anonymous1499355153816007334webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10271)
at <anonymous class>.FirefoxDriver.prototype.findElement(file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/anonymous1499355153816007334webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10280)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/anonymous1499355153816007334webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12274)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/anonymous1499355153816007334webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12279)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/anonymous1499355153816007334webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12221)
页:
[1]