Check miss buton in html page

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Check miss buton in html page

by FastSpeed on Sat Jun 03, 2017 2:44 pm

Hi all, really need your help. Sorry for bad English :oops:
I have the following script:
[spoiler]
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
SET !ERRORIGNORE YES
FILTER TYPE=IMAGES STATUS=ON
URL GOTO= MY LINK
WAIT SECONDS=1
TAG POS=1 TYPE=DIV ATTR=ID:subText >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> the PROBLEM!!!!!!!!!!!!!!!!
TAB T=2
WAIT SECONDS=2
TAG POS=2 TYPE=BUTTON ATTR=TXT:
WAIT SECONDS=1
TAG POS=1 TYPE=DIV ATTR=TXT:
WAIT SECONDS=3
TAG POS=1 TYPE=BUTTON ATTR=TXT:
WAIT SECONDS=2
CLICK X=94 Y=494
WAIT SECONDS=2
CLICK X=102 Y=498
WAIT SECONDS=2
TAG POS=1 TYPE=BUTTON ATTR=TXT:
WAIT SECONDS=3
EVENT TYPE=CLICK SELECTOR="#body-container>DIV:nth-of-type(5)>DIV>DIV>DIV>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(2)>BUTTON:nth-of-type(2)" BUTTON=0
WAIT SECONDS=2
TAB T=1
WAIT SECONDS=3.5
TAG POS=2 TYPE=DIV ATTR=TXT:
WAIT SECONDS=2
TAG POS=1 TYPE=DIV ATTR=TXT:
WAIT SECONDS=1
TAB CLOSEALLOTHERS
[/spoiler]
The problem is that with 5% probability of this button the page will not be available.
[spoiler]
Code: Select all
TAG POS=1 TYPE=DIV ATTR=ID:subText
[/spoiler]
The question, I want to make script Imacros refresh the page (REFRESH), if button is missed. So on until a button appears.
Googled that it is necessary to connect js files
[spoiler]
Code: Select all
var macro;
iimPlayCode('SET !ERRORIGNORE YES');
macro ="CODE:";
macro +="TAG POS=1 TYPE=DIV ATTR=ID:subText";
var ret=null;
ret=iimPlay(macro);
if(ret>0)
{
iimPlayCode('SET !DATASOURCE_LINE 7'); >>>>>>>>>> I Want to start from the seventh lines if the condition is true
iimPlayCode('URL GOTO=imacros://run/?m=Sub2-2.iim');
}
else
{
iimPlayCode('REFRESH')}
[/spoiler]
Have the following problems:
1)if(ret>0), i.e. the condition is true and the button is, I need to continue my script with 7 lines, but js starts it again :mad:
2)the Loop runs indefinitely, and only 1 time.

P. S saw somewhere that to check the element on the page with the command EVAL without connecting JS, but I do not remember where. 1 then the problem will disappear.
FastSpeed
 
Posts: 3
Joined: Sat Jun 03, 2017 2:34 pm

Re: Check miss buton in html page

by chivracq on Sat Jun 03, 2017 4:22 pm

FastSpeed wrote:Hi all, really need your help. Sorry for bad English :oops:
I have the following script:
[spoiler]
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
SET !ERRORIGNORE YES
FILTER TYPE=IMAGES STATUS=ON
URL GOTO= MY LINK
WAIT SECONDS=1
TAG POS=1 TYPE=DIV ATTR=ID:subText >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> the PROBLEM!!!!!!!!!!!!!!!!
TAB T=2
WAIT SECONDS=2
TAG POS=2 TYPE=BUTTON ATTR=TXT:
WAIT SECONDS=1
TAG POS=1 TYPE=DIV ATTR=TXT:
WAIT SECONDS=3
TAG POS=1 TYPE=BUTTON ATTR=TXT:
WAIT SECONDS=2
CLICK X=94 Y=494
WAIT SECONDS=2
CLICK X=102 Y=498
WAIT SECONDS=2
TAG POS=1 TYPE=BUTTON ATTR=TXT:
WAIT SECONDS=3
EVENT TYPE=CLICK SELECTOR="#body-container>DIV:nth-of-type(5)>DIV>DIV>DIV>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(2)>BUTTON:nth-of-type(2)" BUTTON=0
WAIT SECONDS=2
TAB T=1
WAIT SECONDS=3.5
TAG POS=2 TYPE=DIV ATTR=TXT:
WAIT SECONDS=2
TAG POS=1 TYPE=DIV ATTR=TXT:
WAIT SECONDS=1
TAB CLOSEALLOTHERS
[/spoiler]
The problem is that with 5% probability of this button the page will not be available.
[spoiler]
Code: Select all
TAG POS=1 TYPE=DIV ATTR=ID:subText
[/spoiler]
The question, I want to make script Imacros refresh the page (REFRESH), if button is missed. So on until a button appears.
Googled that it is necessary to connect js files
[spoiler]
Code: Select all
var macro;
iimPlayCode('SET !ERRORIGNORE YES');
macro ="CODE:";
macro +="TAG POS=1 TYPE=DIV ATTR=ID:subText";
var ret=null;
ret=iimPlay(macro);
if(ret>0)
{
iimPlayCode('SET !DATASOURCE_LINE 7'); >>>>>>>>>> I Want to start from the seventh lines if the condition is true
iimPlayCode('URL GOTO=imacros://run/?m=Sub2-2.iim');
}
else
{
iimPlayCode('REFRESH')}
[/spoiler]
Have the following problems:
1)if(ret>0), i.e. the condition is true and the button is, I need to continue my script with 7 lines, but js starts it again :mad:
2)the Loop runs indefinitely, and only 1 time.

P. S saw somewhere that to check the element on the page with the command EVAL without connecting JS, but I do not remember where. 1 then the problem will disappear.

Nice Effort in the Post, FCIM for me to have look...(Read my Sig...)
- (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...
chivracq
 
Posts: 6282
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Check miss buton in html page

by FastSpeed on Sun Jun 04, 2017 12:32 am

Full Config info = Win 10x64, MozzilaFirefox 39.00 (my optimized memory catch), Imacros 8.9.7
FastSpeed
 
Posts: 3
Joined: Sat Jun 03, 2017 2:34 pm

Re: Check miss buton in html page

by chivracq on Sun Jun 04, 2017 8:33 am

FastSpeed wrote:Full Config info =
Code: Select all
Win 10x64, MozzilaFirefox 39.00 (my optimized memory catch), Imacros 8.9.7

OK, FCI mentioned, perfect...
Oh..., and good that you are using v8.9.7 (while your Script mentioned v9.0.3) as this Version is more stable than v9.0.3, and I see somewhere in your '.js' Script that you use the 'URL GOTO=imacros://run/?m=' Syntax... which doesn't work anymore in v9.0.3 indeed....

A few Remarks first about your '.js' Script:
- Your "standalone" Statement about '!ERRORIGNORE' is a bit useless and doesn't do anything actually. First you actually don't want to use '!ERRORIGNORE' as you want to check if that Button is present or not, and then all (on-the-fly) Macros played with 'iimPlay()' or 'iimPlayCode()' are "standalone" Macros and don't know anything about the previous one(s) as all (Built-in) Variables are reset.

- Your call to your 'Sub2-2.iim' Macro using the 'URL GOTO=imacros://run/?m=' Syntax is a bit cumbersome as this Syntax is meant as a "Trick" to call another ('.iim' or '.js) Macro from within an '.iim' Macro. It is a Trick and is not supported by Dev/TechSup and indeed it doesn't work anymore in v9.0.3. And I think it doesn't work as well on CR. (But OK, '.js' Scripts don't work on CR either...)
The "standard" way to call your Sub-Macro would be:
Code: Select all
iimPlay("Sub2-2");


Now OK, concerning your Qt, hum..., your Script looks OK to me... It should refresh the Page indeed if that Button is not found... Use 'alert()' to debug your Script and to check that you indeed get "-921" as the ReturnCode.
But, hum..., your "Button" is identified as a 'DIV' and not as a 'BUTTON', it is possible that the 'DIV' is always there on the Page, and therefore always found, but that the Button is contained in the 'DIV', so you may need to tag your Button a bit more "precisely" than at the containing 'DIV' Level...

Another Method which I find a bit more "precise" to identify if your Button is found (rather than just checking the ReturnCode) is to try to tag it with 'EXTRACT', and to use 'iimGetExtract()' in your '.js' Script to build the Condition on the Content of that Extract rather than on the RetCode...

>>>

And otherwise, yep, it is possible to "adapt" your original '.iim' Script to have it loop and click on your Button "only" if it is there and have the "rest" of your Script run "conditionally" using 'EVAL()'..., but it's a little bit "tricky" in your Case, ah-ah...!
A Conditional 'REFRESH' is not possible, but you can use 'URL GOTO' to reload the Page, or you can use indeed the 'URL GOTO=imacros://run/?m=' Syntax you were using to conditionally call a different Macro (or itself...!), and you would probably want all the 'WAIT' Statements to be "Conditional" as well, as I guess you won't want your Script to wait for those each time...
Your Solution with the '.js' Script looks more straightforward to me, if you want my Opinion, ah-ah...!
- (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...
chivracq
 
Posts: 6282
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Check miss buton in html page

by FastSpeed on Sun Jun 04, 2017 10:38 am

Thanks, but I already helped on our Russian forums programmers :D :D You Can close the topic, your answer is not what I was expecting) Version 9.0.3 is too match bugged. I asked about the missing button and it's all possible check this button and refresh page.
FastSpeed
 
Posts: 3
Joined: Sat Jun 03, 2017 2:34 pm

Re: Check miss buton in html page

by chivracq on Sun Jun 04, 2017 4:23 pm

FastSpeed wrote:Thanks, but I already helped on our Russian forums programmers :D :D You Can close the topic, your answer is not what I was expecting) Version 9.0.3 is too match bugged. I asked about the missing button and it's all possible check this button and refresh page.

Hum..., I don't really understand your previous Reply..., except that you managed to solve your Pb with some Russian Programmers, good-good (even if hum "Russian Programmers" => hum, never to be trusted, ah-ah...!, very good, but you always need to check the Code, always trying to open some Backdoor, sorry...!), but post your final Script solving this current Thread with a working Solution or I won't try to help you next time you have a Qt on our Forum... :idea:
- (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...
chivracq
 
Posts: 6282
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Firefox

Who is online

Users browsing this forum: Google [Bot] and 6 guests

-->