iMacros code options

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
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
roco
Posts: 2
Joined: Sat Feb 16, 2019 7:42 pm

iMacros code options

Post by roco » Wed Feb 20, 2019 6:01 pm

Hi guys!

MacOS Mojave Version 10.14.3
Google Chrome Browser Version 72.0.3626.109 (Official Build) (64-bit)
iMacros FREE Version 10.0.5 (VERSION BUILD=1005 RECORDER=CR)

On the one hand, the task can be easy-peasy but on the other hand, it's not. Especially for me :lol:

I have a simple code that works fine so far: it clicks 2 buttons.

Code: Select all

SET !REPLAYSPEED FAST
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 1
WAIT SECONDS=2
TAG POS=1 TYPE=BUTTON ATTR=TXT:Calculate
WAIT SECONDS=2
TAG POS=1 TYPE=BUTTON ATTR=TXT:Ok
Randomly there can appear the third button TYPE=BUTTON ATTR=TXT:Recalculate

What I need is to 'detect' when appears the third button, click on it and continue clicking only 2 buttons until the third appears again.

Can you advise on this? Should I use the 'EVAL' command? If yes, could you be so kind and help a newbie please :oops:
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iMacros code options

Post by chivracq » Wed Feb 20, 2019 8:01 pm

roco wrote:
Wed Feb 20, 2019 6:01 pm
Hi guys!

MacOS Mojave Version 10.14.3
Google Chrome Browser Version 72.0.3626.109 (Official Build) (64-bit)
iMacros FREE Version 10.0.5 (VERSION BUILD=1005 RECORDER=CR)

On the one hand, the task can be easy-peasy but on the other hand, it's not. Especially for me :lol:

I have a simple code that works fine so far: it clicks 2 buttons.

Code: Select all

SET !REPLAYSPEED FAST
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 1
WAIT SECONDS=2
TAG POS=1 TYPE=BUTTON ATTR=TXT:Calculate
WAIT SECONDS=2
TAG POS=1 TYPE=BUTTON ATTR=TXT:Ok
Randomly there can appear the third button TYPE=BUTTON ATTR=TXT:Recalculate

What I need is to 'detect' when appears the third button, click on it and continue clicking only 2 buttons until the third appears again.

Can you advise on this? Should I use the 'EVAL' command? If yes, could you be so kind and help a newbie please :oops:
FCI very clearly mentioned, very good...! :D
And you even mention the 'Free'/'PE' part, I'm impressed...! (The 'PE' Version is only supported on Win OS btw...)

OK..., yeah well, I would think simply including the Tag/Click on your 'Recalculate' Button with '!ERRORIGNORE' (that you already use) would already "do the Trick", and I guess you may want to shorten '!TIMEOUT_STEP' if you don't want your Script to wait for the 6 Sec for when the 'Recalculate' Button is not there, and if your 'WAIT=2' Statements can be a little "flexible", then you can combine both "Waiting" Commands together into stg like... Oh but no!, you already have '!TIMEOUT_STEP=1', which means that your Script will then wait for 3 Sec when the 'Recalculate' Button is not there... But those 3 Sec can in return be shortened back to 2 Sec by shortening your 1st 'WAIT' Statement to only 1 Sec:

Code: Select all

SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 1
WAIT SECONDS=1
TAG POS=1 TYPE=BUTTON ATTR=TXT:Calculate
WAIT SECONDS=2
TAG POS=1 TYPE=BUTTON ATTR=TXT:Ok
TYPE=BUTTON ATTR=TXT:Recalculate
The only "Problem" maybe is if you also need a 'WAIT=2' between the 'Calculate' and the 'Recalculate' Buttons. If 'WAIT=1' between those 2 Buttons is "acceptable", then for example, which will give 2.5 Sec between each Loop for when the 'Recalculate' is not there:

Code: Select all

SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 1
WAIT SECONDS=0.5
TAG POS=1 TYPE=BUTTON ATTR=TXT:Calculate
WAIT SECONDS=2
TAG POS=1 TYPE=BUTTON ATTR=TXT:Ok
WAIT SECONDS=1
TYPE=BUTTON ATTR=TXT:Recalculate
And if you "really" need an "exact" 'WAIT=2' between each 'TAG'/Click on each Button, independently if the 'Recalculate' Button is there or not, then you'll indeed need to use 'EVAL()' to make one of the 'WAIT' Statements "Dynamic" (and/or combined with '!TIMEOUT_STEP' that could also be computed dynamically).

Search the Forum on "Conditional WAIT" (I think...), I've already posted an exact Solution where both the 'WAIT' and the '!TIMEOUT_STEP' were dynamically computed... 8)
I let you search a bit, and try a bit by yourself..., and I'll give you "the" or "a" Solution later on if you don't come out by yourself, but it's not very complicated... 8)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
roco
Posts: 2
Joined: Sat Feb 16, 2019 7:42 pm

Re: iMacros code options

Post by roco » Fri Feb 22, 2019 8:38 pm

Hi chivracq,

Thank you so much for your reply. I've searched for "Conditional WAIT", however, I'm still confused :?
I'm using the "WAIT SECONDS=2" command only to let the page fully load. I'm quite sure that I need the 'EVAL()' command that will help to solve the issue.

I'll try to explain what exactly I need for one of the scenarios:

Initially we have only 2 buttons on the page: 'Calculate' and 'Recalculate'.

First the script clicks on the 'Calculate' button - TAG POS=1 TYPE=BUTTON ATTR=TXT:Calculate
When the script clicks on the 'Calculate' button, appears the second button 'Ok' - TAG POS=1 TYPE=BUTTON ATTR=TXT:Ok
The script clicks on the 'Ok' button and appears the 'Calculate' button again. I play it in a loop.
:!: Please note: the script doesn't click the third button 'Recalculate' at this moment.

After 1-5-10-more minutes the 'Calculate' button disappears and we have only the 'Recalculate' button on the page - TAG POS=1 TYPE=BUTTON ATTR=TXT:Recalculate

I need the iMacros to detect that there is no the 'Calculate' button on the page. And only in this situation click on the 'Recalculate' button :?
Is it possible :?:
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iMacros code options

Post by chivracq » Sat Feb 23, 2019 2:14 am

roco wrote:
Fri Feb 22, 2019 8:38 pm
Hi chivracq,

Thank you so much for your reply. I've searched for "Conditional WAIT", however, I'm still confused :?
I'm using the "WAIT SECONDS=2" command only to let the page fully load. I'm quite sure that I need the 'EVAL()' command that will help to solve the issue.

I'll try to explain what exactly I need for one of the scenarios:

Initially we have only 2 buttons on the page: 'Calculate' and 'Recalculate'.

First the script clicks on the 'Calculate' button - TAG POS=1 TYPE=BUTTON ATTR=TXT:Calculate
When the script clicks on the 'Calculate' button, appears the second button 'Ok' - TAG POS=1 TYPE=BUTTON ATTR=TXT:Ok
The script clicks on the 'Ok' button and appears the 'Calculate' button again. I play it in a loop.
:!: Please note: the script doesn't click the third button 'Recalculate' at this moment.

After 1-5-10-more minutes the 'Calculate' button disappears and we have only the 'Recalculate' button on the page - TAG POS=1 TYPE=BUTTON ATTR=TXT:Recalculate

I need the iMacros to detect that there is no the 'Calculate' button on the page. And only in this situation click on the 'Recalculate' button :?
Is it possible :?:
Yeah, I think you could come out with simply using '!ERRORIGNORE' and your Script will simply click on any Button that is present and "ignore" any Button not present, which sounds OK, if you don't really care if your Script waits for 2 or 3 Sec before trying to click on some Button...

>>>
I need the iMacros to detect that there is no the 'Calculate' button on the page. And only in this situation click on the 'Recalculate' button :?
Is it possible :?:
Yep...:

Code: Select all

TAG POS=1 ['TYPE' + 'ATTR' for that 'Calculate' Button...] EXTRACT=TXT
SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var x,y,z; if(s=='#EANF#'){z=1;} else{z=0;}; z;")
TAG POS={{!VAR1}} ['TYPE' + 'ATTR' for the 'Recalculate' Button...]
'TAG POS=1' will click it, and 'TAG POS=0' won't do anything...

And you can fire a 2nd 'EVAL()' spitting a 0/2 Result to reuse for the 'WAIT' or the '!TIMEOUT_STEP' if you want your Script to wait 0 or 2 Sec for each Command...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iMacros code options

Post by chivracq » Sat Feb 23, 2019 8:27 pm

Oh...!, mini-Detail that I forgot to mention, I realize..., but there is currently a Bug in v10.0.5 for CR, where 'EVAL()' is not able to return a "0" as a Number, (the "0" is "ignored" and an empty String is returned instead), it will probably be fixed in v10.0.6 for CR that should soon be released..., and in the meantime, Workarounds are either to return the "0" as a String (=> "... else{z='0';};...") or "999" for example (as a Number is OK) (=> "... else{z=999;};...")
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: iMacros code options

Post by chivracq » Wed Jun 05, 2019 3:36 pm

Just "saw" you checking the Forum, @roco, and hum..., I realize that more than 3 months later, you didn't follow up anymore on this Thread and didn't finish it "correctly"... :shock:

I won't try to help you again, next time you have a Qt or open a new Thread if you don't finish this one "a bit correctly", as Users not following up on their Threads (+ sharing their Solution/Final Script) is usually a "Show-Killer" for me to help them (again) in the Future..., just saying... :idea:

And hum, I'm "nearly" surprised I had not "complained" a bit about your "iMacros code options" Thread Title and asked you to improve it a bit into stg a bit more Descriptive and Explanatory about its "real" Content... I "normally" don't start helping Users if I have no idea what a Thread is about only from reading its Title, which is the Case for this one... :? I guess I was already impressed that you had very neatly mentioned your FCI, and didn't really pay attention to my other "Quality Criteria" I normally apply... :wink:
=> So "maybe" you could also still change your Thread Title into stg a bit more Descriptive...? :idea:

(And don't worry, I won't ask again...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply