drodbar Posted February 7, 2014 Share Posted February 7, 2014 Hi, I have a web page that has what looks like a drop-down button. When you click it, a menu appears. However, if you view the page source, those items are not present. So I need to be able to click one of these links. If I use: Local $oIE = _IEAttach("My IE Window") Local $sText = _IEBodyReadText($oIE) It returns the names of all of the items in the list. E.g. Item 1 Item 2 Item 3 etc etc However, if I use: Local $oIE = _IEAttach("My IE Window") Local $sText = _IEBodyReadHTML($oIE) It returns the data in a table in the following format: <TR class=MenuTableRow> <TD class=MenuEntryName noWrap>Item1</TD> <TD class=MenuEntryNoSub ARValue="OI-AAAAAAAAAAAAAAAAAAAA005056A603AF"></TD> </TR> <TR class=MenuTableRow> <TD class=MenuEntryName noWrap>Item2</TD> <TD class=MenuEntryNoSub ARValue="OI-BBBBBBBBBBBBBBBBBBBD005056A603AF"></TD> </TR> <TR class=MenuTableRow> <TD class=MenuEntryName noWrap>Item3</TD> <TD class=MenuEntryNoSub ARValue="OI-CCCCCCCCCCCCCCCCCCCC005056A603AF"></TD> </TR> So essentially, there is no "<a href=" for me to select. Does anyone know how I would go about selecting one of these items? I am very new to this, so please assume that I know nothing Thanks in advance for any help. Link to comment Share on other sites More sharing options...
Jury Posted February 9, 2014 Share Posted February 9, 2014 can you give us the url of the web page? once/if you get the table in focus then try: _IETableGetCollection Link to comment Share on other sites More sharing options...
JohnFall Posted February 9, 2014 Share Posted February 9, 2014 I have a similar problem so I hope you don't mind my jumping in here. I've got a working script using _IEGetObjByName and _IEGetObjById and then use _IEAction to click the username field, use send to send my username and then repeat for the password and click login. However on this site https://dashboard.personaltouchfs.com/dashboard/pages/Login.jsp I'm unable to get it working, I'm trying _IETableGetCollection and although the script seems to run ok my username isn't sent so I guess I'm not sending it to the right place? Here's my code snippet. $oTable = _IETableGetCollection($oIE, 1) $oLogin = _IEGetObjByName($oTable, "username") _IEAction($oLogin, "click") Link to comment Share on other sites More sharing options...
Danp2 Posted February 9, 2014 Share Posted February 9, 2014 Here's my code snippet. $oTable = _IETableGetCollection($oIE, 1) $oLogin = _IEGetObjByName($oTable, "username") _IEAction($oLogin, "click") Not sure why you are accessing the table. I would retrieve the form and then access the input controls from there. Also, your code doesn't attempt to supply the user name. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
JohnFall Posted February 9, 2014 Share Posted February 9, 2014 (edited) Argh, no combo of anything from the source of that site seems to work, grrr. My latest iteration is below with the send statement shown:- $oObj = _IEGetObjById($oIE, 'loginForm') $oLogin = _IEGetObjById($oObj, 'username') _IEAction($oLogin, "click") send("xxxxx") Hmm, upon my searches I've seen the rules regarding automated logins, so apologies as I appear to be asking for help with something that is in contravention of this rule. I can assure you my intentions are pure, my goal is to use a previous script that logs in to one site and scrapes the required info and then logs into my back office system to set-up a new client file based on the previously scraped info. I have a working, albeit crude, script that uses send("{TAB}") numerous times to navigate to the correct field but obviously this can be broken should the site get updated. UPDATE - Cracked it $oObj = _IETableGetCollection($oIE, 'loginTable') $oLogin = _IEGetObjByName($oObj, 'username') _IEAction($oLogin, "focus") send("xxxxx") Edited February 9, 2014 by JohnFall Link to comment Share on other sites More sharing options...
Danp2 Posted February 9, 2014 Share Posted February 9, 2014 Don't use Send. Use _IEFormElementSetValue. JohnFall 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
drodbar Posted February 10, 2014 Author Share Posted February 10, 2014 (edited) can you give us the url of the web page? once/if you get the table in focus then try: _IETableGetCollection Unfortunately not, as it's an Intranet site. I've tried the _IETableGetCollection, but this doesn't seem to work, as it doesn't return the table I'm after, which I presume is only generated by Javascript once you click on the relevant button (I could be wrong on that bit). Also, the table that is returned doesn't have a "name" or "id" field. It has a "class" which stays the same for each table item and something called "ARValue", which seems to be unique for each item. Could these be used at all? Edited February 10, 2014 by drodbar Link to comment Share on other sites More sharing options...
Jury Posted February 10, 2014 Share Posted February 10, 2014 I see - personally I'd use Fiddler and upon clicking on one of the links in the table look at the Request header and Miscellaneous header to see whats going on. (also look in initial Result - when you first go to the page containing the table (or from where it is called) to see any hints of what is happening. I clear Fiddler before I go to a web page I want to look at Edit>Remove>All Sessions. Link to comment Share on other sites More sharing options...
drodbar Posted February 11, 2014 Author Share Posted February 11, 2014 (edited) I see - personally I'd use Fiddler and upon clicking on one of the links in the table look at the Request header and Miscellaneous header to see whats going on. (also look in initial Result - when you first go to the page containing the table (or from where it is called) to see any hints of what is happening. I clear Fiddler before I go to a web page I want to look at Edit>Remove>All Sessions. Fiddler looks great, it's certainly given me a lot more information than I'd ever have found before. On looking at the results, it shows that a piece of Javascript is being called which goes something along the lines of: this.result={n:2,f:[{t:4,v:"FieldName"},{t:4,v:"AreaName"},{t:4,v:"ServiceName"},{t:4,v:"CompanyName"},{t:4,v:"ElementFromTableIClicked"},{t:4,v:"All"},{t:4,v:"OI-AAAAAAAAAAAAAAAAAAAAAA5056A603AF"},{ts:1392107835}]};;if(getCurWFC_NS(this.windowID)!=null) getCurWFC_NS(this.windowID).status([]); where: "ElementFromTableIClicked" is the item in the menu I clicked and "OI-AAAAAAAAAAAAAAAAAAAAAA5056A603AF" is the AR Value (see my original post) of that menu item. So does AutoIT give me any way of running that piece of Javascript? I have tried: $oIE.document.parentWindow.eval() $oIE.document.parentwindow.execscript() but both of these do nothing. Edited February 11, 2014 by drodbar Link to comment Share on other sites More sharing options...
JohnFall Posted February 11, 2014 Share Posted February 11, 2014 Don't use Send. Use _IEFormElementSetValue. Thanks Danp2 - great advice there as 'Send' as I've found can be dangerous if focus is taken away. 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