IEFormFill for dynamic content ?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Methuselah
Junior Coder
Posts: 49
Joined: Fri Oct 15, 2004 8:42 am
Location: Johannesburg, South Africa

IEFormFill for dynamic content ?

Post by Methuselah » Mon Sep 16, 2013 12:11 pm

For reasons of reliability and stability, I am hoping to continue using the IE (webrecorder) functions, preferring them to "the other way" of mouse-moves and clicks.
The website I am trying to automate contains dynamically generated selection options ... example data as shown here :
1. Small - Last update 12 Aug
2. Medium - Last update 6 Feb
3. Large - Last update 23 Mar

If the last update changes, the selection string changes and my code fails.
To get around that, I can use the INDEX option as long as that stays static.
( I they add XtraSmall or run out of and so remove Medium, I would also select the wrong one !)

I was hoping for a partial match selection, so tried to send wildcards, but that doesn't seem to work.

Any other ideas .... ?
Is there any way to retrieve the entire content of the select list, perhaps ?

Robin.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Sep 17, 2013 7:00 am

Another approach would be to extract the contents of the SELECT tag, use regex to get an array of all the child OPTION elements, then walk through that array and do your regex/wildcard match to see if this is the option you want. If it is you now know its index. We've used this method a few times for dynamic lists where the index of the desired element cannot be determined any other way.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Methuselah
Junior Coder
Posts: 49
Joined: Fri Oct 15, 2004 8:42 am
Location: Johannesburg, South Africa

Post by Methuselah » Wed Sep 18, 2013 12:57 pm

Yep, that'll do nicely, thank you.
Example code for other forum users.

Code: Select all

IEExtractTag>%IE[0]%,{"frameMain"},{"SELECT"},2,1,SelString
Let>pattern=(?<=<option).*?(?=</option>)
RegEx>pattern,SelString,0,matches,numOpts,0

// Find the "Medium" option   
Let>k=0
Let>Offset=0
Repeat>k
  Let>k=k+1
  Position>Medium,matches_%k%,0,bFound
  If>bFound>0
     Let>Offset=%k%
     Let>k=%NumOpts%
  EndIf
Until>k,numOpts

// Did we find it ?
If>Offset>0
 MessageModal>Found Medium option, Offset=%Offset%
Else
 MessageModal>Medium option not found
EndIf

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts