0

当我尝试通过下面的代码查找输入元素时

driver.findElement(By.cssSelector("input[name=\"passengers[0].passengerName\"]")).sendKeys("xxxxxxxxxxxxxx");

硒抛出以下错误..

org.openqa.selenium.WebDriverException: b.addEventListener is not a function
Command duration or timeout: 16 milliseconds
Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 20:21:45'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.38-13-generic', java.version: '1.6.0_24'
Session ID: e713ccdc-dc05-40a1-923a-8ee51cfa525b
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=16.0.2, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:533)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:302)
        at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:379)
        at org.openqa.selenium.By$ByCssSelector.findElement(By.java:407)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:294)
        at irctcticketbooking.Main.main(Main.java:119)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: b.addEventListener is not a function
Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 20:21:45'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.38-13-generic', java.version: '1.6.0_24'
Driver info: driver.version: unknown
        at <anonymous class>.<anonymous method>(resource://fxdriver/modules/web_element_cache.js:7185)
        at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js:6821)
        at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js:8245)
        at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js:8260)
        at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:10222)
        at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:10227)
        at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:10167)

我试过元素 id、name、css 和 xpath。没有什么有助于摆脱这个例外。

源html文件:https ://dl.dropbox.com/u/345966710/A.html 测试java代码:https ://dl.dropbox.com/u/345966710/Test.java

4

2 回答 2

0

findElementByName("passengers[0].passengerName").sendKeys("P1") 为我工作

使用带有 ff 16 的 java webdriver 2.25 - Windows

也尝试使用 2.28。

于 2013-02-04T14:26:53.667 回答
0

尝试这样的事情

driver.findElement(By.cssSelector("[name*='0'][name*='passengerName']")).sendKeys("test");
于 2013-02-08T13:17:19.017 回答