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

    • DynamicRookie
      By DynamicRookie
      Hey There!
       
      So, what i need to do is an app that can read text in a image (I.e. a png that has text saying "This is a png" and return the text to a variable)
      I'm pretty much a newbie on AutoIt, my purpose is doing that but i don't know any function that can

      Any help is much appreciated
    • santoshM
      By santoshM
      How can i exit from a procedure in auto
      Func test() if x=o then     return endif endFunc  
    • Valnurat
      By Valnurat
      Hi
      Small question.
      I trying to find all index in an array with value higher than 7.
      How can that be possible?
    • TrashBoat
      By TrashBoat
      Could someone help me create or give an idea of how to do a incrementing for loop that would do this: https://i.imgur.com/YFUt47H.gifv
      I'm having a hard time figuring it out :S
    • msd1994
      By msd1994
      I have a script that just adds some keyboard shortcuts for things like displaying the current song and artist, moving the window to the side so it won't pop up in my way, and play/pause, next song, previous song (these are the only 3 to still work since they don't need the window handle.)
      In some update recently, Spotify's window class swapped from "[CLASS:SpotifyMainWindow]" to "[CLASS:Chrome_WidgetWin_0]". Using the new class in my controls doesn't seem to work, I've tried getting the window handle from the process handle (_GetHwndFromPID($PID)) but that seems to fail as well.
      Does anybody have some idea of a way I could get this script working again?
       
      edit: seems like discord has the same window class name, so could be some issue with this? Still not sure of a way to solve the issue though, I added a function to get the handle of the active window and can just use that now, but it was able to find it on its own before on spotify startup or script startup which would be preferred.
       
      Thanks!
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.