grakker Posted June 2, 2016 Share Posted June 2, 2016 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("ctl00$MainContent$DroppedStudents$ClassRptr$ctl01$btnStuProfile", "", false, "", "Helpers/SetStudentAndRedirect.aspx?DU=StudentProfile.aspx&SN=3720", 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 More sharing options...
AutoBert Posted June 2, 2016 Share Posted June 2, 2016 _FFDialogWait should be what you are searching for. Link to comment Share on other sites More sharing options...
grakker Posted June 2, 2016 Author Share Posted June 2, 2016 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 More sharing options...
Danp2 Posted June 2, 2016 Share Posted June 2, 2016 Hard to say without seeing your script. Have you tried setting the active window by calling _FFWindowSelect? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
grakker Posted June 2, 2016 Author Share Posted June 2, 2016 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 More sharing options...
AutoBert Posted June 2, 2016 Share Posted June 2, 2016 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. Link to comment Share on other sites More sharing options...
Danp2 Posted June 2, 2016 Share Posted June 2, 2016 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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
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