Repeat when TAG not found

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
andrewr
Posts: 5
Joined: Tue Jun 19, 2018 7:53 am

Repeat when TAG not found

Post by andrewr » Tue Jun 19, 2018 8:59 am

I'm a newbie in iMacros, and this thing made me frustrated.
Please somebody help me..

This is my macro and I save it as 'upload.iim'

Code: Select all

01. VERSION BUILD=8970419 RECORDER=FX
02. SET !ERRORIGNORE YES
03. SET !TIMEOUT_PAGE 1
04. SET !TIMEOUT_STEP 1
05. URL GOTO=https:****
06. TAG POS=1 TYPE=IMG ATTR=SRC:https:****
07. TAG POS=1 TYPE=BUTTON ATTR=TXT:SUBMIT
08. TAG POS=1 ****
09. TAG POS=1 ****
10. TAG POS=1 ****
11.... (another tag... and so on...)
In line.07 there is as button (SUBMIT) that suppose to tag. But this button does not always shown.
It always shown just a second and then disappear again.
So I put the command SET !ERRORIGNORE YES in line.02.
I playing Loop this macro.. but the SUBMIT button appear only several seconds just when my macro playing line 09-10-11...
By the time it loops the button already disappeared.
I just want if SUBMIT button does not exits (In line.07), the macro will loop from line.07 to line.01 immediatly.

I have found an answer in this forum and the script is :

Code: Select all

var iret = iimPlay("Demo-Extract.iim");

if (iret < 0)
{
  alert("An error occured: " + imacros.iimGetLastError());
}
But I still can't understand it.
Please somebody help me.. Thanks
chivracq
Posts: 8535
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Repeat when TAG not found

Post by chivracq » Tue Jun 19, 2018 11:53 am

andrewr wrote:I'm a newbie in iMacros, and this thing made me frustrated.
Please somebody help me..

This is my macro and I save it as 'upload.iim'

Code: Select all

01. VERSION BUILD=8970419 RECORDER=FX
02. SET !ERRORIGNORE YES
03. SET !TIMEOUT_PAGE 1
04. SET !TIMEOUT_STEP 1
05. URL GOTO=https:****
06. TAG POS=1 TYPE=IMG ATTR=SRC:https:****
07. TAG POS=1 TYPE=BUTTON ATTR=TXT:SUBMIT
08. TAG POS=1 ****
09. TAG POS=1 ****
10. TAG POS=1 ****
11.... (another tag... and so on...)
In line.07 there is as button (SUBMIT) that suppose to tag. But this button does not always shown.
It always shown just a second and then disappear again.
So I put the command SET !ERRORIGNORE YES in line.02.
I playing Loop this macro.. but the SUBMIT button appear only several seconds just when my macro playing line 09-10-11...
By the time it loops the button already disappeared.
I just want if SUBMIT button does not exits (In line.07), the macro will loop from line.07 to line.01 immediatly.

I have found an answer in this forum and the script is :

Code: Select all

var iret = iimPlay("Demo-Extract.iim");

if (iret < 0)
{
  alert("An error occured: " + imacros.iimGetLastError());
}
But I still can't understand it.
Please somebody help me.. Thanks
FCIM...! :mrgreen: (Read my Sig...)
=> iMacros for FF v8.9.7...?, FF v...?, OS...?

Still in pure '.iim' (I don't do/use '.js' Scripts), you can still "tune" the '!TIMEOUT_xxx' Settings like you already tried, and you could set '!TIMEOUT_STEP' to "0", at least after the 'SUBMIT' Button..., if the [08-11] 'TAG' Statements after the Button won't do anything if that Button was not found. :idea:

Or on the contrary, you can set '!TIMEOUT_STEP' to a (much) higher Value and your Script will then simply wait until that Button appears. :idea:
(But this would work only if the Button appears "spontaneously", not if it appears after reloading the Page..., unless you want to manually refresh the Page yourself, or using some other Add-on that would refresh the Page automatically like the 'Auto Refresh' FF Add-on for example...)

But the '!TIMEOUT_STEP' = "0" after the 'TAG' on the Button will already speed up your Script, maybe that's already "good enough" for you...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
andrewr
Posts: 5
Joined: Tue Jun 19, 2018 7:53 am

Re: Repeat when TAG not found

Post by andrewr » Tue Jun 19, 2018 9:30 pm

Mr. chivracq, thanks for your fast response
I'm using iMacros for Firefox 8.9.7, Firefox v.56.0 and Windows 7 Pro x64.
Thanks so much. Your detail answered really help me. Thanks
chivracq
Posts: 8535
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Repeat when TAG not found

Post by chivracq » Wed Jun 20, 2018 2:15 am

andrewr wrote:Mr. chivracq, thanks for your fast response
I'm using

Code: Select all

iMacros for Firefox 8.9.7, Firefox v.56.0 and Windows 7 Pro x64.
Thanks so much. Your detail answered really help me. Thanks
OK, perfect for mentioning your FCI, and good to hear that your Script is working now, you could have posted your final Script, always interesting (for other Users) how you "tuned" it..., but OK, don't worry, good enough for me... :wink:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
andrewr
Posts: 5
Joined: Tue Jun 19, 2018 7:53 am

Re: Repeat when TAG not found

Post by andrewr » Wed Jun 20, 2018 7:17 am

Mr. chivracq, I have already tried your both solutions. And I'm so sorry maybe my question above with no detail information.
The SUBMIT Button does not appear spontaneously, it has to refresh the page in line05
And if this is tagged (clicked), a new page will be loaded in the same tab, and I should tag in this new page again. And so on....

Here is the update :

I set !TIMEOUT_STEP = 0

Code: Select all

01. VERSION BUILD=8970419 RECORDER=FX
02. SET !ERRORIGNORE YES
03. SET !TIMEOUT_PAGE 499
04. SET !TIMEOUT_STEP 0
05. URL GOTO=https:.....
06. TAG POS=1 TYPE=BUTTON ATTR=TXT:SUBMIT  <This button only appears randomly by refreshing page in line 04>
07. TAG POS=1 TYPE=BUTTON ....             <This page only appears if the TAG in line 06 completed>
08. TAG POS=1 TYPE=BUTTON ...              <This page only appears if the TAG in line 07 completed>
09. TAG POS=1 TYPE=IMG ....                <Same as above>
10. TAG POS=1 TYPE=IMG ....                <Same as above>
11. ... (another tag... and so on...)

I play loop with this script, the looping is fast -and line03 makes the page refresh everytime it loops (depends on my internet speed). But just like you wrote before this won't do anything for line 07-11 even if the SUBMIT button appears.
My script should TAG successfully automatic from line 07-11 if the SUBMIT button is already successfully 'clicked' .

I change set !TIMEOUT_STEP = 600 in line 04

Code: Select all

04. SET !TIMEOUT_STEP 600
This doesn't work, because the page is not refresh so the SUBMIT button won't appear.
Then I install auto-refresh addons.
But this won't help either, if the page has refreshed and the SUBMIT is automatically clicked, then my script keeps playing TIMEOUT_STEP because the tag in the next line.07 not found (the page has refresh to earlier page by auto-refresh addons).

So is there any solution for my case?
Thanks Mr.chivracq
chivracq
Posts: 8535
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Repeat when TAG not found

Post by chivracq » Wed Jun 20, 2018 1:08 pm

andrewr wrote:Mr. chivracq, I have already tried your both solutions. And I'm so sorry maybe my question above with no detail information.
The SUBMIT Button does not appear spontaneously, it has to refresh the page in line05
And if this is tagged (clicked), a new page will be loaded in the same tab, and I should tag in this new page again. And so on....

Here is the update :

I set !TIMEOUT_STEP = 0

Code: Select all

01. VERSION BUILD=8970419 RECORDER=FX
02. SET !ERRORIGNORE YES
03. SET !TIMEOUT_PAGE 499
04. SET !TIMEOUT_STEP 0
05. URL GOTO=https:.....
06. TAG POS=1 TYPE=BUTTON ATTR=TXT:SUBMIT  <This button only appears randomly by refreshing page in line 04>
07. TAG POS=1 TYPE=BUTTON ....             <This page only appears if the TAG in line 06 completed>
08. TAG POS=1 TYPE=BUTTON ...              <This page only appears if the TAG in line 07 completed>
09. TAG POS=1 TYPE=IMG ....                <Same as above>
10. TAG POS=1 TYPE=IMG ....                <Same as above>
11. ... (another tag... and so on...)

I play loop with this script, the looping is fast -and line03 makes the page refresh everytime it loops (depends on my internet speed). But just like you wrote before this won't do anything for line 07-11 even if the SUBMIT button appears.
My script should TAG successfully automatic from line 07-11 if the SUBMIT button is already successfully 'clicked' .
Ah OK..., I thought your Script was working now, ah-ah...!

But OK, this one should work, I would think..., even if your "!TIMEOUTPAGE=499" is not very "helpful", I would think, even if you have a very bad Internet Connection..., try this one with a bit "more standard" Values:

Code: Select all

01. VERSION BUILD=8970419 RECORDER=FX
02. SET !ERRORIGNORE YES
03. SET !TIMEOUT_PAGE 10
04. SET !TIMEOUT_STEP 1
05. URL GOTO=https:.....
06. TAG POS=1 TYPE=BUTTON ATTR=TXT:SUBMIT  <This button only appears randomly by refreshing page in line 04>
SET !TIMEOUT_STEP 0
07. TAG POS=1 TYPE=BUTTON ....             <This page only appears if the TAG in line 06 completed>
08. TAG POS=1 TYPE=BUTTON ...              <This page only appears if the TAG in line 07 completed>
09. TAG POS=1 TYPE=IMG ....                <Same as above>
10. TAG POS=1 TYPE=IMG ....                <Same as above>
11. ... (another tag... and so on...)
And you might still need to "tune" the '!TIMEOUT_PAGE', your previous "=1" was very-very short indeed, "standard" Values are usually in the Range [30-60] (60 sec is the Default anyway). It only needs to be high enough for your Button to appear, I guess the Page probably doesn't need to load completely...
But it all depends on your Internet Connection, on the Page of course and how and when this Button will appear, and on the (expected) "Behaviour" associated with the Lines [07-11] 'TAG' Statements as well...
andrewr wrote:I change set !TIMEOUT_STEP = 600 in line 04

Code: Select all

04. SET !TIMEOUT_STEP 600
This doesn't work, because the page is not refresh so the SUBMIT button won't appear.
Then I install auto-refresh addons.
But this won't help either, if the page has refreshed and the SUBMIT is automatically clicked, then my script keeps playing TIMEOUT_STEP because the tag in the next line.07 not found (the page has refresh to earlier page by auto-refresh addons).

So is there any solution for my case?
Thanks Mr.chivracq
Yeah, well the "!TIMEOUT_STEP=600" would only be for the 'SUBMIT' Button of course, then you need to set it back to "1" or "0"...

But hum, this "solution" was indeed meant for if the Button would appear "spontaneously", it might not work indeed if you need to refresh the Page..., and the 'Auto Refresh' was "just an Idea", ah-ah...!, it might indeed interfere with the Statements for Lines [07-11]...
This one ('Auto Refresh') is linked to the Tab it's been activated on, it's not linked to the URL, and it has no Shortcut to enable/disable it (or you could have tried to disable it with the 'EVENT' Mode), maybe you can find another Add-on that can be toggled ON/OFF from a Keyboard Shortcut, or that be linked to specific URL's or with a Blacklist where you could exclude the 2nd URL coming after clicking on your Button (if the URL changes, of course...!).

"So is there any solution for my case?"
=> Tja...!, I don't know, I can only give you some "generic" Advice/Ideas as you didn't post the URL (which probably requires some Login anyway), then I can't "study" the Behaviour of this Site/Page and your "sneaky" Button, ah-ah...! :roll:
Hum, and you've carefully obfuscated/anonymized your Script, then I guess it is probably for a Game/Competition, but I usually refrain from helping with (Cheating on) Games, ah-ah...! :wink:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
andrewr
Posts: 5
Joined: Tue Jun 19, 2018 7:53 am

Re: Repeat when TAG not found

Post by andrewr » Wed Jun 20, 2018 4:20 pm

Haha.. Mr.chivracq, you gave named "sneaky" Button, I agree 100%!
It will appear only for a few second and then disappear again, plus in random times...
Always made me desperate
This is not for a game or competition, this is just a flashsale :(
My simple script (If works) is nothing compare those who use bot-programming. They are more 'sneaky' than the button :D
I'm just a newbie trying to do more than always get 'null' result.
I would rather send you a pm, but it seems you turned this setting off.
Anyway.. thanks so much Mr.chivracq. I'm new in this forum and I can see you answered so many questions from other members, you're the best! THANKS
Last edited by andrewr on Fri Jun 22, 2018 7:15 pm, edited 2 times in total.
chivracq
Posts: 8535
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Repeat when TAG not found

Post by chivracq » Wed Jun 20, 2018 6:15 pm

andrewr wrote:Haha.. Mr.chivracq, you gave named "sneaky" Button, I agree 100%!
It will appear only for a few second and then disappear again, plus in random times...
Always made me desperate
This is not for a game or competition, this is just a flashsale :(
My simple script (If works) is nothing compare those who use bot-programming. They are more 'sneaky' than the button :D
I'm just a newbie trying to do more than always get 'null' result.
I would rather send you a pm, but it seems you turned this setting off.
Anyway.. thanks so much Mr.chivracq. I'm new in this forum and I can see you answered so many questions from other members, you're the best! THANKS
Yeah, you can drop the "Mr.", we have some Technical Ladies on the Forum as well...

Hum..., a "Flashsale" is still some kind of "Competition" for me, I guess you want to be the first to click on that Button..., and I usually don't help for "Financial Benefit" either... (nor for "Social Media" with fake 'Like'/'Follow'/'Comment'/etc, ah-ah...!)

But OK, if your Button remains for a few Seconds, then the Script I posted in my previous Reply should already "do the Job", I would think...
And it can maybe still be improved/tuned a little bit:

Code: Select all

01. VERSION BUILD=8970419 RECORDER=FX
02. SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 2
05. URL GOTO=https:.....

SET !TIMEOUT_PAGE 30
SET !TIMEOUT_STEP 8
06. TAG POS=1 TYPE=BUTTON ATTR=TXT:SUBMIT  <This button only appears randomly by refreshing page in line 04>
SET !TIMEOUT_STEP 1
07. TAG POS=1 TYPE=BUTTON ....             <This page only appears if the TAG in line 06 completed>
SET !TIMEOUT_STEP 0
08. TAG POS=1 TYPE=BUTTON ...              <This page only appears if the TAG in line 07 completed>
09. TAG POS=1 TYPE=IMG ....                <Same as above>
10. TAG POS=1 TYPE=IMG ....                <Same as above>
11. ... (another tag... and so on...)
The Order of all '!TIMEOUT_xxx' Statements is quite "important"...

The first '!TIMEOUT_PAGE=2' for the 'URL GOTO' is deliberately very/too short and the Page probably doesn't succeed to load (completely) in those 2 Sec, or very rarely..., but the following '!TIMEOUT_STEP=8' still allows another 8 Sec for the Page to keep loading, and hopefully your 'SUBMIT' Button to appear in those 8 extra Sec...
But again you might need to "experiment" with different Values for those 2 Settings if you understand the "Principle", it all depends on your Connection + the Site/Page until you find the best "Combination" that works best for you... :wink:
The Sum of 2+8=10 Sec must correspond to the time that your Button will need to appear and be clickable, + maybe 1 or 2 extra Seconds, until you want to "give up" for this Loop and prefer to try again with a Reload of the Page...

Using 'ABP'/'ABE'/'uBlock'/'Ghostery'/etc or any similar Ad/Image/Script Blocker could help as well to kill some unnecessary or "heavy" Ad/Tracking Scripts (or Images) to speed up loading the Page...

>>>

And yep, PM is disabled on the Forum, for everybody, not only me... 8)
(And even if it was enabled, I guess I would have quickly disabled it for myself, ah-ah...!, as I would probably get several PM's everyday :shock: , but I usually only help Users through the Forum...)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
andrewr
Posts: 5
Joined: Tue Jun 19, 2018 7:53 am

Re: Repeat when TAG not found

Post by andrewr » Fri Jun 22, 2018 8:00 pm

I have to quote this..
chivracq wrote:But again you might need to "experiment" with different Values for those 2 Settings if you understand the "Principle", it all depends on your Connection + the Site/Page until you find the best "Combination" that works best for you... :wink:
After searching and keep trying, finally my code running well, fast and smooth.
I combined .iim with .js and tuning the SET !TIMEOUT_PAGE and SET !TIMEOUT_STEP.
From the first moment when I wrote this thread I realize that I should use js, so I had to downgrade my firefox.
I hope iMacros 10 for Firefox beta work fine and I will try it soon.

Many thanks, chivracq. You are the only one who always replied
chivracq
Posts: 8535
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Repeat when TAG not found

Post by chivracq » Fri Jun 22, 2018 8:22 pm

andrewr wrote:I have to quote this..
chivracq wrote:But again you might need to "experiment" with different Values for those 2 Settings if you understand the "Principle", it all depends on your Connection + the Site/Page until you find the best "Combination" that works best for you... :wink:
After searching and keep trying, finally my code running well, fast and smooth.
I combined .iim with .js and tuning the SET !TIMEOUT_PAGE and SET !TIMEOUT_STEP.
From the first moment when I wrote this thread I realize that I should use js, so I had to downgrade my firefox.
I hope iMacros 10 for Firefox beta work fine and I will try it soon.

Many thanks, chivracq. You are the only one who always replied
OK, good to hear... :D

Well, I prefer to do all my Coding in pure '.iim' myself, I don't use any '.js' Script, even if that sometimes requires a little bit of "Creativity", ah-ah...! :twisted:

But hum, about v10 for FF, it looks like '.js' Scripts won't be (natively) supported anymore, at least in a near future, as you can read from a Post from TechSup in the 'v10 for FF Beta Testing' Thread...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Post Reply