帮助!我有AutoIt代码,可以执行以下操作:
这段代码效果很好,我多次使用它!现在, 大约一个月后,它停止了工作 。我检查了HTML页面并没有改变,并且id是相同的。
以下是一些资源:
以下是我尝试访问的 HTML 。我想点击#filename
<fieldset>
<legend>Import step one: upload Word Document</legend>
<h2>Import Word Document: Upload</h2>
<div class="field-group">
<div class="checkbox/radio">
<label for="filename">Upload:</label>
<input id="filename" name="filename" size="50" "="" type="file">
</div>
</div>
<input class="text hidden" name="pageId" value="158367782">
<div class="buttons-container">
<div class="buttons">
<span class="word-file-loading hidden" id="loading">Loading</span>
<input disabled="disabled" id="next" name="submit" value="Next" class="button" type="submit">
</div>
</div>
</fieldset>
这是简化的AutoIt代码,应按#filename
按钮:
; 1) OPEN THE PAGE (WORKS) (I changed the URL)
_FFOpenURL("http://..../")
; 2) WAIT FOR PAGE TO LOAD (WORKS)
_FFLoadWait()
; 3) SLEEP FOR 5 SECONDS (WORKS)
Sleep(5000)
; 4) CLICK THE BROWSE BUTTON (FAILS)
; (SAYS IT IS A SUCCESS BUT THE BUTTON NEVER GETS PRESSED!!)
_FFClick("filename", "id")
; 5) WAIT FOR "FILE UPLOAD" WINDOW TO APPEAR (FAILS)
; (FAILS BECAUSE BUTTON NEVER GOT PRESSED ABOVE)
Local $result = WinWaitActive("File Upload","",10)
这是我的完整自动代码,应按#filename
按钮:
; 1) OPEN THE PAGE (WORKS)
If _FFOpenURL("http://..../") Then
FileWrite($log,"[INFO] Opened Page successfully." & @CRLF)
Else
FileWrite($log,"[ERROR] Could not open Page." & @error & " Extended Error Code = " & @extended & @CRLF)
MsgBox(0, "Error", "Could not open Page.")
Exit
EndIf
; 2) WAIT FOR PAGE TO LOAD (WORKS)
If _FFLoadWait() Then
FileWrite($log,"[INFO] Waited to open page successfully." & @CRLF)
Else
FileWrite($log,"[ERROR] Could not wait for Page." & @error & " Extended Error Code = " & @extended & @CRLF)
MsgBox(0, "Error", "Could not wait for Page.")
Exit
EndIf
; 3) SLEEP FOR 5 SECONDS
Sleep(5000)
; 4) CLICK THE BROWSE BUTTON
; (SAYS IT IS A SUCCESS BUT THE BUTTON NEVER GETS PRESSED!!)
;Click the "Choose File" button
If _FFClick("filename", "id") Then
FileWrite($log,"[INFO] Clicked the 'browse' button successfully." & @CRLF)
Else
FileWrite($log,"[ERROR] Could not click the 'browse' button." & @error & " Extended Error Code = " & @extended & @CRLF)
MsgBox(0, "Error", "Could not click the 'browse' button.")
Exit
EndIf
; 5) WAIT FOR "FILE UPLOAD" WINDOW TO APPEAR
; (FAILS BECAUSE BUTTON NEVER GOT PRESSED ABOVE)
;Wait for the file upload dialog to appear
Local $result = WinWaitActive("File Upload","",10) ;Wait 10 seconds for "File Upload" window to appear
If $result == 0 Then
FileWrite($log,"[ERROR] Waited for 'File Upload' to show, but it never did. " & @error & " Extended Error Code = " & @extended & @CRLF)
MsgBox(0, "Error", " Waited for 'File Upload' to show, but it never did. ")
Exit
Else
FileWrite($log,"[INFO] Opened 'File Upload' dialog successfully. " & @CRLF)
EndIf
以下是Scite控制台显示的错误(我替换了URL):
_FFOpenURL: http://...
__FFSend: try{window.content.top.document.location.href='http://...'}catch(e){'_FFCmd_Err';};
__FFRecv: http://...
_FFLoadWait: ....... loaded in 1688ms
[object HTMLDocument] - {pagetreesearchform: {...}, location: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, write: function() {...}, ...}
__FFSend: FFau3.WCD=window.content.top.document;
__FFRecv: [object HTMLDocument] - {pagetreesearchform: {...}, location: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, write: function() {...}, ...}
[object HTMLDocument] - {pagetreesearchform: {...}, location: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, write: function() {...}, ...}
_FFLoadWait: . loaded in 83ms
[object HTMLDocument] - {pagetreesearchform: {...}, location: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, write: function() {...}, ...}
__FFSend: try{FFau3.simulateEvent(FFau3.WCD.getElementById('filename'),'MouseEvents','click');}catch(e){'_FFCmd_Err';};
__FFRecv: 1
_FFLoadWait: . loaded in 11ms
[object HTMLDocument] - {pagetreesearchform: {...}, location: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, write: function() {...}, ...}
+>11:56:43 AutoIt3.exe ended.rc:0
+>11:56:43 AutoIt3Wrapper Finished.
这是我的版本信息: