Sign in to follow this  
Followers 0
drodbar

Trying to click on items from a table

10 posts in this topic

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 :D

Thanks in advance for any help.

Share this post


Link to post
Share on other sites



can you give us the url of the web page?  once/if you get the table in focus then try: _IETableGetCollection

Share this post


Link to post
Share on other sites

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")
 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by JohnFall

Share this post


Link to post
Share on other sites

Don't use Send. Use _IEFormElementSetValue.

1 person likes this

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by drodbar

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by drodbar

Share this post


Link to post
Share on other sites

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.

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
Sign in to follow this  
Followers 0