Extract Table Info & Display it in PROMPT

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
jhodgson14
Posts: 6
Joined: Tue Apr 16, 2019 12:57 pm

Extract Table Info & Display it in PROMPT

Post by jhodgson14 » Fri Apr 26, 2019 11:30 am

Hi There,

Firstly, Windows 10, Free, CR75(DEV), VERSION BUILD=1005 RECORDER=CR

Objective: Extract two pieces of information from order pages and display them to the user in a PROMPT dialog box.

At the end of an ordering process we use it gives you the info you need on two separate pages which is quite annoying. The info is provided in a table on each page and I'm wondering if there is a better method than what I currently have in mind.

Currently this is my script;

Code: Select all

TAG POS=1 TYPE=A ATTR=TXT:Assemble
TAG POS=7 TYPE=TABLE ATTR=TXT:* EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
TAG POS=1 TYPE=A ATTR=TXT:Assembled
TAG POS=2 TYPE=A ATTR=TXT:Assemble
TAG POS=7 TYPE=TABLE ATTR=TXT:* EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=TXT:Assembled
SET !VAR2 {{!EXTRACT}}
SET !VAR3 ("'{{!VAR1}}'.concat('{{!VAR2}}')");
PROMPT "{{!VAR3}}
The table that each site gives looks like this;
Screen Shot 2019-04-26 at 12.09.11.png
Of course currently after the concat, the info is presented like this in the PROMPT window
Screen Shot 2019-04-26 at 12.23.23.png
My javascript knowledge is limited so the only way I know to get this to make sense would be lots of substrg's & slices.

Is there a better way to achieve this end goal?

Many Thanks J
chivracq
Posts: 8636
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract Table Info & Display it in PROMPT

Post by chivracq » Fri Apr 26, 2019 1:58 pm

jhodgson14 wrote:
Fri Apr 26, 2019 11:30 am
Hi There,

Firstly,

Code: Select all

Windows 10, Free, CR75(DEV), VERSION BUILD=1005 RECORDER=CR
Objective: Extract two pieces of information from order pages and display them to the user in a PROMPT dialog box.

At the end of an ordering process we use it gives you the info you need on two separate pages which is quite annoying. The info is provided in a table on each page and I'm wondering if there is a better method than what I currently have in mind.

Currently this is my script;

Code: Select all

TAG POS=1 TYPE=A ATTR=TXT:Assemble
TAG POS=7 TYPE=TABLE ATTR=TXT:* EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
TAG POS=1 TYPE=A ATTR=TXT:Assembled
TAG POS=2 TYPE=A ATTR=TXT:Assemble
TAG POS=7 TYPE=TABLE ATTR=TXT:* EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=TXT:Assembled
SET !VAR2 {{!EXTRACT}}
SET !VAR3 ("'{{!VAR1}}'.concat('{{!VAR2}}')");
PROMPT "{{!VAR3}}
The table that each site gives looks like this;
Screen Shot 2019-04-26 at 12.09.11.png

Of course currently after the concat, the info is presented like this in the PROMPT window
Screen Shot 2019-04-26 at 12.23.23.png

My javascript knowledge is limited so the only way I know to get this to make sense would be lots of substrg's & slices.

Is there a better way to achieve this end goal?

Many Thanks J
Alright... OK, you are making a few "Mistakes": :wink:
1- You need to add a "SET !EXTRACT NULL" just before the 2nd 'EXTRACT', or the 1st 'EXTRACT' is also taken into your '!VAR2'.
2- 'concat()' is a JS Method, and can only be used inside 'EVAL()' when you are constructing your '!VAR3'.
3- And even with 'EVAL()', your final ';' would also need to be inside 'EVAL()', before the closing _")_.

Instead of 'concat()' you can also use a simple '+' to concatenate 2 Strings. The Syntax is much simpler...
Instead of 'EVAL()' + 'concat()' (or '+'), you can also use the 'ADD' Command.
You can also do the Concatenation and final Layout directly in the 'PROMPT' by using '<SP>' (Space) and '<BR>' (Line Break):

Code: Select all

PROMPT VAR1:<SP>_{{!VAR1}}_<BR><BR>VAR2:<SP>_{{!VAR2}}_
(Avoid using any '!' from '!VARn' for example directly in the 'PROMPT' for displaying Text or you get some "unpredictable" Results as iMacros then thinks those will be Input Vars...)

BUT...!, I think I had noticed that v10.0.x for CR has a Bug with '<BR>' in the 'PROMPT' which is replaced by a Space, you might want to try with '\r' instead (without the Single Quotes). I'm a bit "surprised" nobody ever reported it and complained, I guess '\r' or '\r\n' is probably the Workaround and all Users managed to find it...

And hum..., the 'EXTRACT' on the 'TYPE=TABLE' is maybe a little bit "too powerful" for your Need, you might want to only extract the few Fields that you "really" need/want in the 'PROMPT' instead of extracting all Cells from those 2 Tables as it also extracts the Title and many empty Cells...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
jhodgson14
Posts: 6
Joined: Tue Apr 16, 2019 12:57 pm

Re: Extract Table Info & Display it in PROMPT

Post by jhodgson14 » Wed May 08, 2019 10:17 am

Hi Chivracq,

Thanks for the above I got it working in the end!

The only thing that I'm struggling with is the line break, can't seem to get <BR>, \r or \r\n to work within the Prompt window. It just put the command in as part of the Plain Text. Any thoughts?

Thanks Jake
chivracq
Posts: 8636
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract Table Info & Display it in PROMPT

Post by chivracq » Wed May 08, 2019 2:52 pm

jhodgson14 wrote:
Wed May 08, 2019 10:17 am
Hi Chivracq,

Thanks for the above I got it working in the end!

The only thing that I'm struggling with is the line break, can't seem to get <BR>, \r or \r\n to work within the Prompt window. It just put the command in as part of the Plain Text. Any thoughts?

Thanks Jake
Oh...!, some Follow-up, about 2 weeks later, youpidoo...!! 8)

Hum, "got it working", yeah well, then post/share your final/current Script... :idea:

About the Line Break, I'll see from your "current" Script to do some Testing..., if I can find some Workaround, as I think, I had noticed this "buggy" Behaviour, but I'm surprised nobody ever mentioned/complained (about) it...
But hum, that's v10.0.5 for CR, pfff..., Grrr..., I hate this stupid CR Browser that takes about 1/2 hour each time to start, (as I only use it for the Forum), before it has updated itself + any Add-ons/Plugins...

OK, and don't take 2 weeks to follow up again, that's too long for me... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 8636
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract Table Info & Display it in PROMPT

Post by chivracq » Fri May 10, 2019 5:34 am

Hum, and I guess I won't be "impressed' by the Follow-up "AGAIN"...!!, no Reply AGAIN 2 days later..., sorry but this a bit "ridiculous" AGAIN...! :roll:

OK, good luck if anybody else replies and tries to help you but I'm a bit "out"... :x :|
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply