grakker

FF.au3 Javascript Click on Button Question

7 posts in this topic

I have a page with a bunch of links that look like this:

<input type="submit" name="ctl00$MainContent$DroppedStudents$ClassRptr$ctl01$btnStuProfile" value="" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$MainContent$DroppedStudents$ClassRptr$ctl01$btnStuProfile&quot;, &quot;&quot;, false, &quot;&quot;, &quot;Helpers/SetStudentAndRedirect.aspx?DU=StudentProfile.aspx&amp;SN=3720&quot;, false, false))" id="ctl00_MainContent_DroppedStudents_ClassRptr_ctl01_btnStuProfile" title="View Student Profile" class="dim-link student-profile" />

I'm able to parse the page and end up with an array of `name` references that look like this:
 

ctl00$MainContent$ClassRptr$ctl01$btnStuProfile
ctl00$MainContent$ClassRptr$ctl02$btnStuProfile
ctl00$MainContent$ClassRptr$ctl03$btnStuProfile
ctl00$MainContent$ClassRptr$ctl04$btnStuProfile
ctl00$MainContent$ClassRptr$ctl05$btnStuProfile

I can't figure out how to use the Firefox UDF to click on these. I have installed and tested MozRepl and it works. I want to do something like:

For $row in $array
    _FFLinkClick($row, "name")
Next

Well, I'm going to do more than just click those links, but I can't even get that to work. Right now my error looks like:

_FFConnect: OS: WIN_7 WIN32_NT 7601 Service Pack 1
_FFConnect: AutoIt: 3.3.14.2
_FFConnect: FF.au3: 0.6.0.1b-15
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect: Socket:     580
_FFConnect: Browser:    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0
__FFSendJavaScripts: Sending functions to FireFox .......... done
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//a[contains(@name,'ctl00$MainContent$ClassRptr$ctl01$btnStuProfile')]",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: _FFXPath_Error: TypeError: can't access dead object
__FFSend: try{FFau3.simulateEvent(0,'MouseEvents','click');}catch(e){'_FFCmd_Err';};
_FFXPath ==> Error return value: _FFXPath_Error: TypeError: can't access dead object
__FFRecv: -3

I have looked at the samples, but I just can't figure out how to do this. I think that it is something with _FFXPath, but that documentation stumps me as well.

Share this post


Link to post
Share on other sites



_FFDialogWait should be what you are searching for.

Share this post


Link to post
Share on other sites

I don't think that is what I'm looking for. Basically, I have a page with a list of links. Each link I want to click, wait for the page to open, process it (this part I have working!), then close it and click the next link. This ends up being between 100-200 links. Tedious to not automate.

Share this post


Link to post
Share on other sites

Hard to say without seeing your script. :blink:

Have you tried setting the active window by calling _FFWindowSelect?

Share this post


Link to post
Share on other sites

Here is most of the script:

 

#Include <FF.au3>
#Include <Array.au3>

;open source page, copy and close
WinWait("https://aeries.hbuhsd.edu/Aeries.net/TeacherAttendance.aspx - Mozilla Firefox")
send("^u")
Sleep(1550)
Send("^a")
Send("^c")
$raw = ClipGet()
Send("^x")

$Source = StringSplit($raw, @LF, 1)
;_ArrayDisplay($Source)
Global $Just_Links = []

;Take the entire page and parse out the links
For $i = 1 to $Source[0]
    If Stringinstr($Source[$i], "ctl00_MainContent_ClassRptr_") And StringInStr($Source[$i], "btnStuProfile") Then
        $Source[$i] = StringMid(StringStripWS($Source[$i], 4), 29, 47)
        ;$Source[$i] = Stringreplace($Source[$i], "$", "_")
        _ArrayAdd($Just_Links, $Source[$i])
    EndIf
Next

_ArrayDelete($Just_Links, 0)
;_ArrayDisplay($Just_Links)

If _FFConnect(Default, Default, 3000) Then
    for $row In $Just_Links
        WinWaitActive("Class Attendance")
        Sleep(1000)
        _FFLinkClick($row, "name")
    Next
EndIf

The only trouble I'm having is the loop.

Share this post


Link to post
Share on other sites
9 minutes ago, grakker said:

The only trouble I'm having is the loop.

i understood your trouble is a JS-Window, sorry for my missunderstanding and good luck.

Share this post


Link to post
Share on other sites

Have you tried using _FFReadHTML to capture the page source? I would expect that to work much better than your current method.

You could also use _FFLinksGetAll to get an array of all links and then process the array to find the desire links.

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

    • Marc
      By Marc
      Profiler - yet another backup script for Firefox and Thunderbird profiles
      It automatically detects the last recently used profile directories of Firefox and Thunderbird (installed versions, no portables).
      Clicking the Backup-Button creates a complete Backup of the found profiles with a timestamp.
      Restore deletes the according profile dir and extracts the content of the selected archive into the profile directory.
      Uses Winrar as compression tool, but feel free to change it to your needs
      Best regards
      Marc

      Profiler.au3
    • BOUNCER
      By BOUNCER
      I'm trying to get the output data from https://www.guilded.gg but it uses a web app that generates that output on the fly and this doesn't show up in the page source.
      Only in web inspector of each browser does this data show up. How do I read this data in autoit (equivalent to the web inspector)
       
      thank you
    • Patryk
      By Patryk
      Dear Colleagues,
      I have no idea how to refer to style.display in my loop. There is a button like: 
      <input name="ctl00$bodyPlaceholder$btnFecharProcessamento" class="button" id="bodyPlaceholder_btnFecharProcessamento" style="display: none;" onclick="FecharJanelaProcessamento();return false;" type="submit" value="Fechar"> I want it to be clicked as soon as button's style change from style="display: none;" to  style= ="display: inline-block;" 
      This is what I got, but it's not working...
      Func GetButtons() $oButtons = _IEGetObjByName($oForm,"ctl00$bodyPlaceholder$btnFecharProcessamento",-1) $i = 0 While $i <> 1 For $oBtn In $oButtons If _IEFormElementGetValue($oBtn) = "Fechar" And $oBtn.document.style.display = "display: inline-block;" Then $i = 1 _IEAction($oBtn, "focus") _IEAction($oBtn, "click") ExitLoop EndIf Next WEnd EndFunc  
      I will really appreciate if you could help me with these loop!
    • Pao
      By Pao
      Hello, I've recently updated from Firefox 50 to 54.0.1.
      My Autoit script that previously worked fine, now seems to have erratic problems.
      It's almost as if some Send() commands are sometimes skipped when dealing with the Firefox UI (it's still mostly fine on the actual pages).

      To temporarly fix the problem, I had to put some Sleep(200) pauses and avoid grouping keys together (e.g: TAB 2), but I'm not exactly sure about the correct way to deal with this..
      Could this be caused by the new multiprocess feature? (e10s)
      Are there better Autoit commands or rules that I should use?
       
    • Omnitica
      By Omnitica
      Hello!
      I'm new to the forums! Couldn't find any threads covering this issue. Sorry if I'm wrong.

      I'm having problems changing the text/value of a input box. The particular box doesn't have a name or id, just: class="jq_hotkeys_enabled form-control".
      This class appears multiple times throughout the source, so I don't think It's right to reference that object. 
      See image 1.
      However, I've managed to find a object with the name "ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper" which contains the value of the input box, and the id for the person in the dropdown/combobox left of it. (with "dummy-1" selected).
      See image 2.
      As you can see the value is 3982,4545     ( name , time )
      But when I try to change the value of it by doing:
      #include <IE.au3> Local $oIE = _IEAttach(WinGetHandle("[CLASS:IEFrame]"),"embedded") Local $oForm = _IEFormGetObjByName($oIE, "aspnetForm") Local $oInput = _IEFormElementGetObjByName($oForm, "ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper") _IEFormElementSetValue($oInput, "3982,1337") The box doesn't get its new value. I  can see in the source that it's changed though.
      See image 3.
       
      However, if I do: 
      #include <IE.au3> Local $oIE = _IEAttach(WinGetHandle("[CLASS:IEFrame]"),"embedded") Local $oForm = _IEFormGetObjByName($oIE, "aspnetForm") Local $oInput = _IEFormElementGetObjByName($oForm, "ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper") _IEFormElementSetValue($oInput, "3982,1337") $oIE.document.parentwindow.execScript("theForm.submit()") ; But it needs to reload the page The box gets its new value after the page reloads by the theForm.submit() function. 
      This is a bit unfortunate as I want the changes to happen instantly like when I type in the box with the keyboard... or select in the combobox.
      Maybe someone knows how I can do this? Looking forward to an answer! 
      Thanks in advance.
       
      Note: Unfortunately I can't provide with the real URL as it is constricted to employees in the company I work for, but let me know If I should provide anything else.