|
初学selenium,遇到往富文本框写入内容的疑问,在浏览器console中写入文本能成功,程序中报错写入代码为
String s = "document.getElementById('ueditor_0').contentWindow.document.body.innerText='test';";
((JavascriptExecutor)driver).executeScript(s);
报错信息为
debug1org.openqa.selenium.WebDriverException: document.getElementById(...) is null
Command duration or timeout: 24 milliseconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'USER-20140421LD', ip: '192.168.1.122', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=30.0, platform=XP, browserConnectionEnabled=true, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 5dfa34b2-2b5f-400a-b498-94809f546e85
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:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:504)
at com.x2.Todo.testAddTodo(Todo.java:90)
at com.x2.Todo.main(Todo.java:39)
浏览器console能写进内容
document.getElementById('ueditor_0').contentWindow.document.body.innerText='test';
"test"
|
|