kt Posted March 23, 2016 Posted March 23, 2016 NOTE: MY STACK OVERFLOW QUESTION HERE ALSO: http://stackoverflow.com/questions/36162810/autoit-firefox-automation-ffclick-doesnt-work-on-buttons-anymore-ff-au3 Help! I had AutoIt code that would do the following: 1. load a page in FireFox, then 2. click on the 'browse' button, then 3. waits for the File Upload window to appear This code worked great and I used it many times! Now, about a month later, it stopped working. I checked the HTML page and it did NOT change, and the id is the same. Here are some resources: _FFOpenURL _FFLoadWait _FFClick WinWaitActive ControlClick Full list of FF.au3 functions Here is the HTML that I am trying to access. I am trying to click on #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> Here's my simplified AutoIt code that should press the #filename button: ; 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) Here is my full autoit code that should press the #filename button: expandcollapse popup ; 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 Here is the errors shown from the Scite console (I replaced the 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. And here is my version information: - AutoIt v3.3.14.2 - SciTE v3.6.0 - Firefox v44.0.2 - Firefox AutoIt Plugin - FF V0.6.0.1b-15.au3 (Docs) - Firefox Plugin for using AutoIt - [MozRepl][10] 1.1.2.1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now