Jump to content
kt

Help! _FFClick doesn't work on buttons anymore? (FF.au3)

Recommended Posts

kt

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:

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:

    ; 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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • mar3011
      By mar3011
      hello, I want to set in the inputbox field random key from the keyboard to which the function will be assigned, for example F4 function start notepad ALT + A function start notepad for one function. Thank you for any help.  
    • JuanFelipe
      By JuanFelipe
      Cambiar a español Hello friends, I need help with a problem I have, I want to know if there is any way to update a GUI already running, that is I have a GUI of a certain size and with a button I would like to enlarge it:
      example: $ form1 = GUICreate ("", 200,100,0,0)   When you press the button, the gui increases its size, and actuates the new size.
    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

       
      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • santoshM
      By santoshM
      Dear friends i am facing a problem , i have created a window in autoit some time it is moving with the mouse curser even if iam not clicking the window 
    • sumanth1980
      By sumanth1980
      Here i am wrote a simple lines to install basic applications but when i clicked on one application/program to install it was working fine but when i cancel the program in the middle to install another program it was not working. I am not an expert in this but i want a solution for this ... Can any one help me on this....
      ORG-1.au3
×