Jump to content

FF.au3 Javascript Click on Button Question


Recommended Posts

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.

Link to comment
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.

Link to comment
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.

Link to comment
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
 Share

×
×
  • Create New...