找回密码
 加入
搜索
查看: 3009|回复: 4

[IE类操作] ie操作时遇到很诡异的错误,不解...[已解决]

[复制链接]
发表于 2011-9-14 09:09:03 | 显示全部楼层 |阅读模式
本帖最后由 jack2684 于 2011-9-14 21:41 编辑

请看下面两个段代码,第一个是没问题的。第二个问题很诡异,运行循环的时候会报IE.au3里面的error,而且每次报的时机行数还未必会相同!!
比如有时报
If String($oItem.type^ ERROR
,有时报
_IETagNameGetCollection($oTemp, "input")^error
(还会报其他错误,我就不贴出来了),太令人无解了


第二段代码只是在第一段的基础上多加了几行而已.(多加的那几行我贴在后面)

这是没问题的代码:
Func _JwcSelect($goIE)
        $cir=1
        $c=0
        $bottomFrame=_IEFrameGetObjByName($goIE,"bottomFrame")
        $menuFrame=_IEFrameGetObjByName($bottomFrame,"menuFrame")
        While $cir
                
                _IELinkClickByTitle($menuFrame,"id","individual",1)
                $mainFrame=_IEFrameGetObjByName($bottomFrame,"mainFrame")
                $gsMainFrame=$mainFrame
                ;_IELinkClickByTitle($mainFrame,"name","pagelink",2)
                $courses=_IEFrameGetObjByName($gsMainFrame,"inforUpContent")
                If $courses==0 Then
                        GUICtrlSetData($Edit1,"框架获取失败,重试。。。"& @CRLF,1)
                        $cir=1
                        Sleep(500)
                        ContinueLoop
                EndIf
                $oForm=_IETagNameGetCollection ($courses,"form",1)
                ;MsgBox(0,"form数量",@extended)
                If @extended=0 Then
                        GUICtrlSetData($Edit1,"列表失败,重试。。"& @CRLF,1)
                        $cir=1
                        Sleep(500)
                        ContinueLoop
                EndIf
                
                If _IEFormElementCheckboxSelect($oForm,0,"",1,"byIndex")<>0 Then
                        _JwcConfirm($goIE)
                        GUICtrlSetData($Edit1,"<DONE>"& @CRLF,1)
                Else
                        $c+=1
                        GUICtrlSetData($Edit1,"<"&$c&">",1)
                EndIf
                ;$cir=_IELinkClickByTitle($gsMainFrame,"name","pagelink",1)
                ;If $cir=0 Then
                ;        GUICtrlSetData($Edit1,"时间结束..."& @CRLF,1)
                ;EndIf
                _IELoadWait($goIE)
                Sleep(500)
        WEnd
EndFunc

这是有诡异问题的代码
Func _JwcSelect($goIE)
        $cir=1
        $c=0
        $bottomFrame=_IEFrameGetObjByName($goIE,"bottomFrame")
        $menuFrame=_IEFrameGetObjByName($bottomFrame,"menuFrame")
        While $cir
                
                _IELinkClickByTitle($menuFrame,"id","individual",1)
                $mainFrame=_IEFrameGetObjByName($bottomFrame,"mainFrame")
                $gsMainFrame=$mainFrame
                ;_IELinkClickByTitle($mainFrame,"name","pagelink",2)
                $oCourses=_IEFrameGetObjByName($gsMainFrame,"inforUpContent")
                If $oCourses==0 Then
                        GUICtrlSetData($Edit1,"框架获取失败,重试。。。"& @CRLF,1)
                        $cir=1
                        Sleep(500)
                        ContinueLoop
                EndIf
                $oSelected=_IEGetObjByName($oCourses,"kch")
                _IEDocInsertText($oSelected,GUICtrlRead($input5))
                $searchs=$oCourses.document.images
                For $search In $searchs
                        If $search.title=="过滤" Then
                                $search.click
                                ExitLoop
                        EndIf
                Next
                
                $oForm=_IETagNameGetCollection ($oCourses,"form",1)
                ;MsgBox(0,"form数量",@extended)
                If @extended=0 Then
                        GUICtrlSetData($Edit1,"列表失败,重试。。"& @CRLF,1)
                        $cir=1
                        Sleep(500)
                        ContinueLoop
                EndIf
                
                If _IEFormElementCheckboxSelect($oForm,0,"",1,"byIndex")<>0 Then
                        _JwcConfirm($goIE)
                        GUICtrlSetData($Edit1,"<DONE>"& @CRLF,1)
                Else
                        $c+=1
                        GUICtrlSetData($Edit1,"<"&$c&">",1)
                EndIf
                ;$cir=_IELinkClickByTitle($gsMainFrame,"name","pagelink",1)
                ;If $cir=0 Then
                ;        GUICtrlSetData($Edit1,"时间结束..."& @CRLF,1)
                ;EndIf
                _IELoadWait($goIE)
                Sleep(500)
        WEnd
EndFunc

这是第二段相对于第一段增加的部分,就是一个“写入”和“点击”的动作而已
$oSelected=_IEGetObjByName($oCourses,"kch")
                _IEDocInsertText($oSelected,GUICtrlRead($input5))
                $searchs=$oCourses.document.images
                For $search In $searchs
                        If $search.title=="过滤" Then
                                $search.click
                                ExitLoop
                        EndIf
                Next
 楼主| 发表于 2011-9-14 10:09:04 | 显示全部楼层
刚才又试了试,把下面的代码注释了就没有bug,太神奇了吧(下面的代码只是筛选用的,注释了不影响运行)
我怎么都找不到下面这么简单的一小段代码为什么会有奇怪的bug.....
$oSelected=_IEGetObjByName($oCourses,"kch")
                _IEDocInsertText($oSelected,GUICtrlRead($input5))
                $searchs=$oCourses.document.images
                For $search In $searchs
                        If $search.title=="过滤" Then
                                $search.click
                                ExitLoop
                        EndIf
                Next
 楼主| 发表于 2011-9-14 10:16:35 | 显示全部楼层
现在大概能确定就是:$oSelected=_IEGetObjByName($oCourses,"kch")引起错误(尽管每次在ie.au3错误的位置未必一样)。唉。。。。为啥会错呢。。。
 楼主| 发表于 2011-9-14 21:40:25 | 显示全部楼层
最后无意发现这个和载入有关,加了个_IELoadWait()就貌似解决了
发表于 2011-9-17 01:27:13 | 显示全部楼层
全部都让你搞掂了啊,good
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 04:10 , Processed in 0.083233 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表