I am trying to check if the element does exist in webpage.
I saw how it's done in this simple stuff previously, Check if html element exists with iMacros and javascript
(I want to comment there, but it said need 50 rep minimum)
The simple stuff I meant was like this.
var macro;
macro ="CODE:";
macro +="TAG POS=1 TYPE=DIV ATTR=CLASS:some_class CONTENT=EVENT:MOUSEOVER ";
var ret=null;
ret=iimPlay(macro);
if(ret>0)
{
//do something
}
else
{
//do something else
}
But unfortunately, when it comes to several line check.. As I needed to add , to make the whole proccess running more efficiently..
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 2
The return of this ret variable will always 1 (I prompted it's value with different cases). So the else condition will never met.
What should I do?
UPDATE: (actual case) The case here, element of webpage is not visible until you scrolled to it. Say you are on Facebook. The button "Add Comment" is not visible until you're scrolled to the article element. It would work with this algorithm.
// loop start
for(;;){
iimplaycode(*hover tag:nth-of-type(i)*);
x=iimplaycode(*check if add comment is there*);
if(x>0){
//if it's there, do comment
iimplaycode();
}
//loop to 2nd element
}
See the problem now? If I am not using the !TIMEOUT_STEP
, the checking of "add comment" would be take long (6 second).. Just want to maximize performance by lowering it's value to 1,2 seconds or so.