Linking two macros - second to execute based on condition (404 error)

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
samatyranin
Posts: 4
Joined: Sat Nov 27, 2021 3:02 pm

Linking two macros - second to execute based on condition (404 error)

Post by samatyranin » Sat Nov 27, 2021 3:20 pm

Hey guys,

I've just discovered iMacros. It its great tool that may in future help me with many tasks. But I've found it today as I was looking for some kind of automation tool for one of the websites. It is gov site with some certificates that I have to confirm. There are about 50-100 of them daily. And while I had no idea that I have to do that now I have bit over 12000 of them. Thing about this website is that it lags as hell (sometimes when it has to load next page it needs over 60 seconds to do so - crashing that macro with timeout). But that's not a big deal. What concerns me the most is fact that it tends to crash with 404 error (and it is not automation failure because it also happens when you click it manually). So I've created second macro that goes through that 404 error so I can start another loop of first one to continue with process of clicking.

So here are both of them:

Code: Select all

VERSION BUILD=10101485
TAG POS=3 TYPE=BUTTON ATTR=TXT:Opcje
TAG POS=1 TYPE=A ATTR=TXT:Edycja/Zmiana<SP>statusu
TAG POS=1 TYPE=BUTTON FORM=ID:WasteTransferTransportCardForm ATTR=TXT:Zmień<SP>status
TAG POS=1 TYPE=A ATTR=TXT:Potwierdź<SP>transport
TAG POS=1 TYPE=A ATTR=TXT:Zrealizowane<SP>przejęcie
and below is the 'error handler' in case of that 404 error:

Code: Select all

VERSION BUILD=10101485
URL GOTO=https://rejestr-bdo.mos.gov.pl/Error/404
TAG POS=1 TYPE=A ATTR=TXT:Powrót<SP>do<SP>strony<SP>głównej
TAG POS=1 TYPE=SPAN ATTR=TXT:Ewidencja<SP>odpadów
TAG POS=1 TYPE=SPAN ATTR=TXT:Karty<SP>przekazania
TAG POS=1 TYPE=SPAN ATTR=TXT:Karty<SP>przekazania<SP>odpadów
TAG POS=1 TYPE=A ATTR=TXT:Transportujący
TAG POS=1 TYPE=A ATTR=TXT:Zrealizowane<SP>przejęcie
What I want to do if that 404 error pops up with URL stated in second macro to stop executing first one then run through that second macro and then get back to looping first one. As far as I got into documentation there are no contionals like 'if something then something'. I've noticed that some of the topics stated that you need to link both of these with JS which I totally dont know at all.

Only thing I've seen is to use iimPlay command (viewtopic.php?t=3454) but still no idea how to create that JS file and how to then link it to execute second macro only if after any steps of first one it gets to that 404 page. Any ideas how to fix that so I can not just sit at it all day because it crashes usually after less than 10 loops.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Linking two macros - second to execute based on condition (404 error)

Post by chivracq » Sat Nov 27, 2021 3:46 pm

samatyranin wrote:
Sat Nov 27, 2021 3:20 pm
Hey guys,

I've just discovered iMacros. It its great tool that may in future help me with many tasks. But I've found it today as I was looking for some kind of automation tool for one of the websites. It is gov site with some certificates that I have to confirm. There are about 50-100 of them daily. And while I had no idea that I have to do that now I have bit over 12000 of them. Thing about this website is that it lags as hell (sometimes when it has to load next page it needs over 60 seconds to do so - crashing that macro with timeout). But that's not a big deal. What concerns me the most is fact that it tends to crash with 404 error (and it is not automation failure because it also happens when you click it manually). So I've created second macro that goes through that 404 error so I can start another loop of first one to continue with process of clicking.

So here are both of them:

Code: Select all

VERSION BUILD=10101485
TAG POS=3 TYPE=BUTTON ATTR=TXT:Opcje
TAG POS=1 TYPE=A ATTR=TXT:Edycja/Zmiana<SP>statusu
TAG POS=1 TYPE=BUTTON FORM=ID:WasteTransferTransportCardForm ATTR=TXT:Zmień<SP>status
TAG POS=1 TYPE=A ATTR=TXT:Potwierdź<SP>transport
TAG POS=1 TYPE=A ATTR=TXT:Zrealizowane<SP>przejęcie
and below is the 'error handler' in case of that 404 error:

Code: Select all

VERSION BUILD=10101485
URL GOTO=https://rejestr-bdo.mos.gov.pl/Error/404
TAG POS=1 TYPE=A ATTR=TXT:Powrót<SP>do<SP>strony<SP>głównej
TAG POS=1 TYPE=SPAN ATTR=TXT:Ewidencja<SP>odpadów
TAG POS=1 TYPE=SPAN ATTR=TXT:Karty<SP>przekazania
TAG POS=1 TYPE=SPAN ATTR=TXT:Karty<SP>przekazania<SP>odpadów
TAG POS=1 TYPE=A ATTR=TXT:Transportujący
TAG POS=1 TYPE=A ATTR=TXT:Zrealizowane<SP>przejęcie
What I want to do if that 404 error pops up with URL stated in second macro to stop executing first one then run through that second macro and then get back to looping first one. As far as I got into documentation there are no contionals like 'if something then something'. I've noticed that some of the topics stated that you need to link both of these with JS which I totally dont know at all.

Only thing I've seen is to use iimPlay command (viewtopic.php?t=3454) but still no idea how to create that JS file and how to then link it to execute second macro only if after any steps of first one it gets to that 404 page. Any ideas how to fix that so I can not just sit at it all day because it crashes usually after less than 10 loops.

(F)CIM...! :mrgreen: (Read my Sig... :idea: , + maybe the Forum Rules, when you join a Tech Forum... :idea: )
=> FCI:

Code: Select all

iMacros v10.1.0 for FF...?, 'Free'/'PE'/'Trial'...?, FF v...?, OS...?
=> Mention your FCI for me to "start" answering your Thread...
- (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...
samatyranin
Posts: 4
Joined: Sat Nov 27, 2021 3:02 pm

Re: Linking two macros - second to execute based on condition (404 error)

Post by samatyranin » Sat Nov 27, 2021 4:32 pm

Well Build ID is there in Macro header. Browser too - firefox 94.0.2. Freeware version of iMacros and Win11
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Linking two macros - second to execute based on condition (404 error)

Post by chivracq » Sat Nov 27, 2021 6:03 pm

samatyranin wrote:
Sat Nov 27, 2021 4:32 pm
Well Build ID is there in Macro header. Browser too -

Code: Select all

firefox 94.0.2. Freeware version of iMacros and Win11

=> FCI:

Code: Select all

iMacros v10.1.0 for FF, 'Free', FF94, Win11.
"Well Build ID is there in Macro header."
=> Yeeaaaaahhhh, the `VERSION` Statement only "gives a Hint" in which Browser/iMacros Version you "ever" recorded a Script, it doesn't tell "for sure" in which FCI you are running the Script, iMacros Scripts can be recorded in one Browser, ... and played in a different one...

"Browser too"
=> Hum, "normally" yep, but `RECORDER` Param not visible/included in your Script, not sure if you've removed it, or if v10.1.0 for FF doesn't record it anymore, I don't use this Version myself...

And anyway, simply mention your FCI (preferably at the very Top of your OP) when you open a Thread on the Forum, or I simply don't answer, period... :idea:

>>>

OK, quick Answer, I'm "awaited" to eat at some Friend's, I may post a "longer" Reply "a bit later" when I'm "back"...

The `iimPlay()` Command that you mention, correctly about linking/connecting/playing together several Macros is not supported in your v10.x Version for FF, you would need to use v8.9.7 for FF to be able to use that Functionality... (... Which might be a "very good Option" indeed... But I might have a "better Solution", ah-ah...!)

Alright, I had a look at the Site, and like I "suspected", it is indeed using those "PITA" (Pain in the Ass) 'Let's Encrypt' Certificates, renewed every 3 months, and that cause a lot of Pb's, especially with older Browsers like in PM26 that I still use as Default Browser for my own Automation, but FF55 managed to open the Site "without complaining", with the same Certificate, and your FF94, which is much more "recent" than "my" FF55, shouldn't "complain" either, I would expect... :|

I would have a "Way" to already click on the "Add Exception..." Button if needed, I didn't try any further with the 2nd Level of Popup Confirm Dialogs...

But anyway, from what I understand from your Scenario, and what you mention as being the most important Part of your Scenario ("What concerns me the most is fact that it tends to crash with 404 error"), I think in your Case, the "easiest" Implementation would be to "simply" combine both Scripts into one..., like for example...:

Code: Select all

VERSION BUILD=10101485
'SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 90
SET !TIMEOUT_STEP 1
TAG POS=3 TYPE=BUTTON ATTR=TXT:Opcje
TAG POS=1 TYPE=A ATTR=TXT:Edycja/Zmiana<SP>statusu
TAG POS=1 TYPE=BUTTON FORM=ID:WasteTransferTransportCardForm ATTR=TXT:Zmień<SP>status
TAG POS=1 TYPE=A ATTR=TXT:Potwierdź<SP>transport
TAG POS=1 TYPE=A ATTR=TXT:Zrealizowane<SP>przejęcie

'Handle 404 Errors:
'URL GOTO=https://rejestr-bdo.mos.gov.pl/Error/404
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=A ATTR=TXT:Powrót<SP>do<SP>strony<SP>głównej
TAG POS=1 TYPE=SPAN ATTR=TXT:Ewidencja<SP>odpadów
TAG POS=1 TYPE=SPAN ATTR=TXT:Karty<SP>przekazania
TAG POS=1 TYPE=SPAN ATTR=TXT:Karty<SP>przekazania<SP>odpadów
TAG POS=1 TYPE=A ATTR=TXT:Transportujący
TAG POS=1 TYPE=A ATTR=TXT:Zrealizowane<SP>przejęcie
- (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...
samatyranin
Posts: 4
Joined: Sat Nov 27, 2021 3:02 pm

Re: Linking two macros - second to execute based on condition (404 error)

Post by samatyranin » Sat Nov 27, 2021 8:16 pm

So...

iMacros v10.1.0.1485 for FF, 'Free', FF94.0.2 Win11

About stuff that you wrote further - I'm not really into web dev so shorts like 'Pb's', 'PM26' doesn't ring a bell for me ;]

And I was indeed thinking about merging two macros together. But I did not think that it is more or less just pasting one after another. It works almost perfect. I had to comment out

Code: Select all

SET !TIMEOUT_STEP 1
because it was usually stuck when site did not load properly after certain (short time). And apart from that it runs way longer now especially when there are some kind of errors on the way. I can just pop it on and leave for it to go through 100 runs more or less without an issue (and while previous macro barely got past 20 runs until it broke.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Linking two macros - second to execute based on condition (404 error)

Post by chivracq » Sat Nov 27, 2021 8:58 pm

samatyranin wrote:
Sat Nov 27, 2021 8:16 pm
So...

Code: Select all

iMacros v10.1.0.1485 for FF, 'Free', FF94.0.2  Win11
About stuff that you wrote further - I'm not really into web dev so shorts like 'Pb's', 'PM26' doesn't ring a bell for me ;]

And I was indeed thinking about merging two macros together. But I did not think that it is more or less just pasting one after another. It works almost perfect. I had to comment out

Code: Select all

SET !TIMEOUT_STEP 1
because it was usually stuck when site did not load properly after certain (short time). And apart from that it runs way longer now especially when there are some kind of errors on the way. I can just pop it on and leave for it to go through 100 runs more or less without an issue (and while previous macro barely got past 20 runs until it broke.

Alright, good News then...! :D

About the Abbreviations that I used:
- Pb = Problem
- PM = 'Pale Moon' (Browser forked on FF ('Firefox')), => PM26 = 'Pale Moon' v26.

Well, about "my" "SET !TIMEOUT_STEP 1", because I had increased your Default =60 Sec to =90 Sec for `!TIMEOUT_PAGE`, as you mentioned that the Site could be sometimes a bit slow and that the Default =60 Sec would sometimes be too short, that "automatically" also increased `!TIMEOUT_STEP` to =9 Sec (= 10% of `!TIMEOUT_PAGE` if not specifically set in the Macro), and I "thought" that =9 Sec might be a bit too long, but you can "tune" that Setting yourself to find the "best Balance" between Speed and Reliability, => maybe =3 Sec or =6 Sec, if =1 Sec is "too short", although the =0 Sec seems to works for the 2nd Part of the Script, when you get some 404 Error...

+ You could also maybe try to enable the "SET !ERRORIGNORE YES" that I placed (disabled) at the beginning of your Script..., then your Script should run even longer... :idea:
Oh...!, but you are using the 'Free' Version, then Looping is limited to 100 anyway, ah-ah...!, although if you paste the whole Script again +1 or +2 times (within the 50-Line Limit of the 'Free' Version), you could get the "Equivalent" of 200 or 300 Loops with just 100 "real" Loops... :idea:
... Or "invest" in the 'PE' Version ('Personal Edition') and you will be able to use the "Full" Version without any Limits, and Looping is then Unlimited... :P
- (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...
samatyranin
Posts: 4
Joined: Sat Nov 27, 2021 3:02 pm

Re: Linking two macros - second to execute based on condition (404 error)

Post by samatyranin » Sat Nov 27, 2021 9:36 pm

Thanks! I'll wiggle around a bit with step timeout then. Thing is that those loading times for pages are all over the place. Page usually loads in less than 1 second. But when it lags then it is anything from 1 to like 90 seconds or more. And copying whole macro 2 or 3 times is also good idea. I'd probably stick with freeware version anyway. Mostly because of the fact that once I click through all that stuff then it wouldnt be a problem to click through these 50 or so that adds to the list on a daily basis. Even if I'd like to automate this with iMacros then these 50 loops are within the freeware limits.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Linking two macros - second to execute based on condition (404 error)

Post by chivracq » Sat Nov 27, 2021 9:52 pm

samatyranin wrote:
Sat Nov 27, 2021 9:36 pm
Thanks! I'll wiggle around a bit with step timeout then. Thing is that those loading times for pages are all over the place. Page usually loads in less than 1 second. But when it lags then it is anything from 1 to like 90 seconds or more. And copying whole macro 2 or 3 times is also good idea. I'd probably stick with freeware version anyway. Mostly because of the fact that once I click through all that stuff then it wouldnt be a problem to click through these 50 or so that adds to the list on a daily basis. Even if I'd like to automate this with iMacros then these 50 loops are within the freeware limits.

Alright, sounds like you are "all set" then, Thanks for the Feedback and "neat" Follow-up..., and glad I could help... :D :wink:
- (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