2013-02-04 52 views
0

當我試圖找到通過下面的代碼異常在硒的webdriver:b.addEventListener不是函數

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/[email protected]/components/driver_component.js:6821) 
     at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/[email protected]/components/driver_component.js:8245) 
     at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/[email protected]/components/driver_component.js:8260) 
     at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/[email protected]/components/command_processor.js:10222) 
     at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/[email protected]/components/command_processor.js:10227) 
     at <anonymous class>.<anonymous method>(file:///tmp/anonymous8377906034759035727webdriver-profile/extensions/[email protected]/components/command_processor.js:10167) 

I」已經嘗試過元素ID,名稱,CSS和XPath。沒有任何幫助擺脫這種例外。

HTML源文件:https://dl.dropbox.com/u/345966710/A.html 測試Java代碼:https://dl.dropbox.com/u/345966710/Test.java

+0

您將需要共享你企圖用互動..附加文件的 –

+0

@niharika_neo源片的HTML。 – user2039615

回答

0

findElementByName("passengers[0].passengerName").sendKeys("P1")作品對我來說

用java 2.25的webdriver與FF 16 - 視窗

與2.28試圖爲好。

+0

你試過用java嗎?我希望你用javascript測試了代碼。它可以在Ubuntu和Windows中重現。 – user2039615

+0

僅供參考,我使用硒2.28.0。這個例外是什麼意思? – user2039615

+0

你可以顯示你的驅動程序的init代碼嗎?主方法中的行號119包含什麼? –

0

嘗試是這樣的

driver.findElement(By.cssSelector("[name*='0'][name*='passengerName']")).sendKeys("test"); 
+0

@santhosh再次得到了相同的結果例外:源html文件和java代碼示例已附加,如果你測試了,你會自己看到。 – user2039615