ckelsoe Posted July 26, 2013 Share Posted July 26, 2013 First off - I am really loving what I am seeing with the IE automation. The app I am automating is very poorly designed so that part is a struggle. But the results are golden The web app I am automating heavily uses nested tables. When I use _IETableGetCollection($oIE,-1) I find that there are four tables. that are nested in a frame. I am able to get data out of some of the tables - but it is not from the table I need it from. I am thinking that the issue is I am addressing the wrong frame. Here is what I have so far: #include <IE.au3> #include <Array.au3> $URL="https://someurl.com/" Local $oIE = _IECreate($URL,1,1,1,1) ; Presses the search button to change to the search window. _IELinkClickByText($oIE, "SEARCH") _IELoadWait($oIE, 250) Local $oForms = _IEFormGetCollection($oIE) Local $oFrame = _IEFrameGetObjByName($oIE, "main") $iFrame = _IEFrameGetObjByName($oFrame, "bottom") Local $oForm = _IEFormGetObjByName ($iFrame, "search") Local $oQuery1 = _IEFormElementGetObjByName($oForm,"ClientNumber") Local $ClientNumber = "18590" ;ClipGet() _IEFormElementSetValue ($oQuery1,$ClientNumber) _IEFormSubmit($oForm) _IELoadWait($oIE, 500) ; Look at the results $oTable = _IETableGetCollection($oIE,1) ;$oTable = _IETableGetCollection($oIE,-1 ;Returns 4 although there are many more tables nested.) ;Local $iNumTables = @extended ;MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page") $aTableData = _IETableWriteToArray($oTable) _ArrayDisplay($aTableData) I am wondering if there is a limited to the level of nested tables that the functions can see or do I need to somehow get the functions to look at the "bottom" iframe page? I wish I could show you the website but it is proprietary, behind firewalls and vpn tunnels, etc. It is a piece of work though. Link to comment Share on other sites More sharing options...
Edano Posted July 26, 2013 Share Posted July 26, 2013 nice to see that you get along with _ie.au3 [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Danp2 Posted July 26, 2013 Share Posted July 26, 2013 Are you able to post an HTML file that would be representative of the site you are accessing? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Edano Posted July 26, 2013 Share Posted July 26, 2013 if you are able to access it, you should also be able to download it and post the html code here. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
ckelsoe Posted July 26, 2013 Author Share Posted July 26, 2013 (edited) I will have to heavily sanitize the html. Let me have a go at that and see. And yes I am loving the power and potential of ie.au3. Edited July 26, 2013 by ckelsoe Link to comment Share on other sites More sharing options...
ckelsoe Posted July 26, 2013 Author Share Posted July 26, 2013 (edited) Removed html code that was here due to the proprietary nature of it. Edited July 28, 2013 by ckelsoe Link to comment Share on other sites More sharing options...
Danp2 Posted July 27, 2013 Share Posted July 27, 2013 The code you posted references iframes that I don't see in the HTML you posted. Can you post the results from the output window when you run this in sciTE? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Edano Posted July 27, 2013 Share Posted July 27, 2013 cool. will look tomorrow. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
ckelsoe Posted July 27, 2013 Author Share Posted July 27, 2013 The second code window is the html out of the bottom iframe. I am not sure what more I can post about this. I can see 4 tables in the table collection but not the rest. It does appear that no tables from the bottom iframe are found. So I think the issue is I need help figuring out how to get into the tables in the iframe. Link to comment Share on other sites More sharing options...
Danp2 Posted July 27, 2013 Share Posted July 27, 2013 So the "bottom" iframe is nested inside the "main" iframe? Is $iFrame still valid after the initial form submission? If so, have you tried changing the code to use, $iFrame instead of $oIE, ie: $oTable = _IETableGetCollection($iFrame,1) Still would like to see the results show in the Output window. This would help identify where the code is failing. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Edano Posted July 27, 2013 Share Posted July 27, 2013 (edited) i think i found your error. . $oTable = _IETableGetCollection($oIE,1) . according to helpfile, . $o_object Object variable of an InternetExplorer.Application, Window or Frame object $i_index [optional] specifies whether to return a collection or indexed instance0 or positive integer returns an indexed instance-1 = (Default) returns a collection . so, you use 1 as index to show the content of table 1 instead, use -1 to get a collection. cheers E. Edited July 27, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Edano Posted July 27, 2013 Share Posted July 27, 2013 (edited) ; ******************************************************* ; Example 1 - Open a browser with the table example, get a reference to the first table ; on the page (index 0) and read its contents into a 2-D array ; ******************************************************* #include <IE.au3> Local $oIE = _IE_Example("table") Local $oTable = _IETableGetCollection($oIE, 0) Local $aTableData = _IETableWriteToArray($oTable) ; ******************************************************* ; Example 2 - Open a browser with the table example, get a reference to the ; table collection and display the number of tables on the page ; ******************************************************* #include <IE.au3> $oIE = _IE_Example("table") $oTable = _IETableGetCollection($oIE) Local $iNumTables = @extended MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page") . helpfile example Edited July 27, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Edano Posted July 27, 2013 Share Posted July 27, 2013 (edited) when i transfer that to your code, i get "there are 13 tables on the page" . ;http://www.autoitscript.com/forum/topic/152996-ie-nested-tables-how-to-get-to-a-nested-table/#entry1099716 ;Post #1 ;D:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\SLICER\Avatar\default_large.png ;by ckelsoe ;Script grabbed by SLICER by Edano here: http://www.autoitscript.com/forum/topic/152402-slicer-autoit-forum-script-grabber/?p=1093575 #include <IE.au3> #include <Array.au3> $URL=@ScriptDir&"\tables.html" Local $oIE = _IECreate($URL,1,1,1,1) ; Presses the search button to change to the search window. _IELinkClickByText($oIE, "SEARCH") _IELoadWait($oIE, 250) Local $oForms = _IEFormGetCollection($oIE) Local $oFrame = _IEFrameGetObjByName($oIE, "main") $iFrame = _IEFrameGetObjByName($oFrame, "bottom") Local $oForm = _IEFormGetObjByName ($iFrame, "search") Local $oQuery1 = _IEFormElementGetObjByName($oForm,"ClientNumber") Local $ClientNumber = "18590" ;ClipGet() _IEFormElementSetValue ($oQuery1,$ClientNumber) _IEFormSubmit($oForm) _IELoadWait($oIE, 500) $oTable = _IETableGetCollection($oIE) Local $iNumTables = @extended MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page") . bingo ,now you can choose your table index Edited July 27, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
ckelsoe Posted July 27, 2013 Author Share Posted July 27, 2013 Yes that works fine on a single html page. However it does not work in the actual Iframe configuration. I will continue to work with this and hopefully get something working. Every page I need to access is built this way so it is something that I have to figure out before moving forward. The code $oTable = _IETableGetCollection($oIE,1) is correct to address a specific table I believe - so $oTable = _IETableGetCollection($oIE,10) would address the 9th or 10th table (depending on if the count starts at 0 or 1). My problem is specific to getting it to look at the tables in the bottom iframe page. Link to comment Share on other sites More sharing options...
Danp2 Posted July 27, 2013 Share Posted July 27, 2013 Not sure if you saw my earlier post >here. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ckelsoe Posted July 27, 2013 Author Share Posted July 27, 2013 Yes - playing with that code. I am getting the WEnd error in _IELoadWait. I think I saw something about this being fixed in an updated IE.au3 file which requires the beta of AutoIt. Not sure how stable the beta is and if I want to try it. Any thoughts on that? Link to comment Share on other sites More sharing options...
ckelsoe Posted July 27, 2013 Author Share Posted July 27, 2013 Well here is another clue: There are two embedded IFrames. The second one also contains a FrameSet with two additional frames. So off I go to figure out how to get into that... Link to comment Share on other sites More sharing options...
Danp2 Posted July 27, 2013 Share Posted July 27, 2013 Beta runs just fine for me. You can run the beta along side the release version, so there's nothing to lose with trying it. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ckelsoe Posted July 29, 2013 Author Share Posted July 29, 2013 (edited) Ok - I have put the following together so you can see the mess. I have put in the iframes and tables so you can get an idea of the scope of the page and where the data is I need to get to. My brain is fried at the moment from trying to get something working. I can automate with mouse clicks, however, that is dependent on the resolution, etc. as many of the buttons and ahref's that need clicked move depending on the IE window size. Using the DOM will insure that the solution will work no matter how IE is on the desktop. I have made some notes throughout indicating where I need to click, send info, and possibly retrieve information for use in some logic. Here is the html outline. (edited to add initial frame info at the top I forgot to include last night. I did not add all of the table and div elements above and below from the other framesets.) expandcollapse popup<iframe> <Frameset id=fset> <frame id=navigation> <frame id=fraEntity name=middle> <html> <head> </head> <body> <form name="form1" method="post" id="form1"> <div> </div> <div> <!--Top Tab--> <table> <tr> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td> <table> <tr> <td></td> <td></td> </tr> </table> </td> <td></td> <td></td> <td></td> <td></td> <td/></td> </tr> </table> </td> </tr> <tr> <td> <div> <!--End Top Tab--> <table> <tr> <td> <!--Menu tab--> <table> <tr> <td> <table id="Table12"> <tr> <td>Text ahref</font></td> </tr> <tr> <td>Text ahref</td> </tr> <tr> <td>Text ahref</td> </tr> <tr> <td>Text ahref</td> </tr> <tr> <td>Text ahref I want to click</td> <!-- Note to self - data in URL string of this ahref that could be used --> </tr> <tr> <td>Text ahref</td> </tr> <tr> <td>Text ahref</td> </tr> <tr> <td>Text ahref</td> </tr> <tr> <td>Text ahref</td> </tr> <tr> <td>Text ahref</td> </tr> <tr> <td>Text ahref</td> </tr> <tr> <td>Text ahref</td> </tr> <tr> <td>Text ahref</td> </tr> </table> </td> </tr> </table><!--End Menu tab--> </td> <td> <table> <tr> <td> <iframe id="container" name="contents"> <!-- This iframe is where the editing takes place --> <!-- Begin html from page referenced in iframe --> <html> <head> </head> <body> <form method="post" name="edits"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td</td> <td> <!-- Need to click this button once form data is filled out --> <input type="button" value="Generate Edit" id="btnCreate" name="btnCreate" onclick="this.disabled=true;submitPage();"/> </td> </tr> <tr> <td> <table> <tr> <td></td> <td> <table> <tr> <td></td> <td></td> </tr> </table> </td> </tr> <tr> <td></td> <td> <!-- Send text to this input field --> <input name="desc" type="text" id="txtDescription"/></td> </tr> <tr> <td></td> <td></td> </tr> </table> </td> </tr> <tr> <td> <div> <table> <tr> <td> <div id="_main"> <div> <table> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </table> </div> <table> <tr> <td></td> </tr> <tr> <td></td> </tr> <tr> <td> <div> <table> <tr> <td></td> <td> <table> <tr> <td></td> <td></td> </tr> </table> </td> </tr> <tr> <td></td> <td></td> <td></td> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </td> <td></td> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </td> <td></td> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </td> <td></td> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </td> <td></td> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </td> <td></td> <td> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </td> <td></td> <td></td> </tr> <tr> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> </tr> </table> </div> </td> </tr> <tr> <td></td> </tr> <tr> <td></td> </tr> <tr> <td> <table> <tr> <td> <table> <tr> <td>ColA Title</td> <td></td> <td>Col B Title</td> <td>Col C Title</td> <td>Col D Title</td> <td>Col E Title</td> <td>Col F Title</td> <td>Col G Title</td> <td>Col H Title</td> <td>Col I Title</td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td> <table> <tr> <td> <table> <tr> <td>Col A Data</td> <td>Col B Data</td> <td>Col C Data</td> <td>Col D Data</td> <td>Col E Data</td> <td>Col F Data</td> <td>Col G Data</td> <td>Col H Data</td> <!-- Data here I may want to read into a variable --> <td>Col A Data</td> <td>Col A Data</td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </div> </td> </tr> </table> </div> </td> </tr> </table> </form> </body> </html> <!-- End html from page referenced in iframe --> </iframe> </td> </tr> </table> </td> </tr> </table><!--Bottom Tab--> </div> </td> </tr> <tr> <td> <table> <tr> <td/></td> <td/></td> <td/></td> <td/></td> <td/></td> </tr> <tr> <td/></td> <td/></td> <td/></td> <td/></td> <td/></td> </tr> <tr> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td/></td> <td></td> </tr> </table> </td> </tr> </table><!--End Bottom Tab--> </div> </form> </body> </html> Edited July 29, 2013 by ckelsoe Link to comment Share on other sites More sharing options...
ckelsoe Posted July 29, 2013 Author Share Posted July 29, 2013 Well I have made little progress. Not nearly what I needed to get done. I have figured out how to provide a better image of the DOM from DebugBar using a scrolling Snagit screen capture. I have made some notes on the image. Any thoughts, guidance, and feedback is appreciated. 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