日期:2014-05-16  浏览次数:20366 次

document.getElementById 问题!
document.getElementById( "sltIssueFromYear ").selectedIndex=year-2006;  
在下拉列表中显示当前年份的脚本!


大家好!

                  我在用http   unit   编写   测试程序时,发现页面的javascript   的方法     document.getElementById   无法识别!   该如何解决?


系统提示:

Event   'crruteDate() '   failed:   TypeError:   Cannot   convert   null   to   an   object.   (httpunit;   line   9)
at   com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.handleScriptException(JavaScript.java:203)
at   com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.performEvent(JavaScript.java:176)
at   com.meterware.httpunit.scripting.ScriptableDelegate.doEvent(ScriptableDelegate.java:56)
at   com.meterware.httpunit.WebResponse$Scriptable.load(WebResponse.java:691)
at   com.meterware.httpunit.javascript.JavaScript.load(JavaScript.java:89)
at   com.meterware.httpunit.javascript.JavaScriptEngineFactory.load(JavaScriptEngineFactory.java:58)
at   com.meterware.httpunit.RequestContext.runScripts(RequestContext.java:44)
at   com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:122)
at   com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:102)
at   com.meterware.httpunit.WebClient.getResponse(WebClient.java:87)
at   com.idsp.testcase.JobManage.jobSearch(JobManage.java:79)
at   com.idsp.testcase.IdspTest.main(IdspTest.java:43)


------解决方案--------------------
document.all.sltIssueFromYear用all来取,或者forms[0]也行.
------解决方案--------------------
这个不太可能,这种方法大多浏览器都支持!
你仔细检查下你的代码!
------解决方案--------------------
Event 'crruteDate() ' failed: TypeError: Cannot convert null to an object.

这句说明是year本身没有获取正确的值。看看你的java文件里面的否正确赋值了。或者将该值和2006用javascript强制转换成为date对象再计算试试。
------解决方案--------------------
(This is a bug in 6.0).
If you try to do a interactive Connection command using a scripted Connectors or a scripted Parsers attached to a Connector then you will get the above error if you have used the main object in your Connector. Your AssemblyLine will work fine when you run it, it is only when you interactively use the Connect functionality that it will fail.

那个工具没用过,不知道是做什么的,不过找到些资料,上面这段差不多意思就是说不能进行交互式的脚本
------解决方案--------------------
document.getElementById浏览器无法识别??
web 2.0规范都建议用的方式,绝大多数浏览器都支持的啊...........
------解决方案--------------------
这种模拟点击的情况最好放在页面,有javascript来模拟