Using tab Buttons on an HTML page - timeout

Discussions and Tech Support related to the iMacros Google Chrome extension.
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
tonnyb01
Posts: 9
Joined: Wed Aug 10, 2016 2:22 pm

Using tab Buttons on an HTML page - timeout

Post by tonnyb01 » Wed Aug 10, 2016 2:58 pm

Using tab Buttons on an HTML page

Using the free Chrome attachment.
Windows 7 64 bit
Chrome Version 52.0.2743.116 m

I have a Imacros script that activates a button which sends data to a server, which then sends data back to me. The data submission retrieval part is handled by a php script. Sometime the sever takes too long and the Imacros script times out. How do I get the Imacros script to wait for the info to load before executing the BACK command? I am currently using the WAIT SECONDS command to get this to work but sometimes 1 sec isn't enough and the script times out; it seems that there must be a better way to do this. Here is part of the current script I am using.

VERSION BUILD=8350307 RECORDER=CR
URL GOTO=http://localhost/asin3.htm
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:a2.php ATTR=NAME:Submitbutton
WAIT SECONDS = 1
BACK
TAG POS=2 TYPE=INPUT:SUBMIT FORM=ACTION:a2.php ATTR=NAME:Submitbutton
WAIT SECONDS = 1
BACK
TAG POS=3 TYPE=INPUT:SUBMIT FORM=ACTION:a2.php ATTR=NAME:Submitbutton
WAIT SECONDS = 1
BACK

...

TAG POS=160 TYPE=INPUT:SUBMIT FORM=ACTION:a2.php ATTR=NAME:Submitbutton
WAIT SECONDS = 1
BACK
...

Thanks
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Using tab Buttons on an HTML page - timeout

Post by iimfun » Thu Aug 11, 2016 10:03 am

1. First of all I recommend rewriting the macro so that you could play it in loop mode

Code: Select all

SET locUrl http://localhost/asin3.htm
SET currUrl EVAL("({{!LOOP}} == 1) ? '{{locUrl}}' : 'javascript:void(0);';")
URL GOTO={{currUrl}}

TAG POS={{!LOOP}} TYPE=INPUT:SUBMIT FORM=ACTION:a2.php ATTR=NAME:Submitbutton
WAIT SECONDS=1
BACK
2. Let's assume that the server response is something like "... Submission is OK ! ...". So your macro may look like

Code: Select all

' max extra time to wait for the server response
SET !TIMEOUT_STEP 3
SET locUrl http://localhost/asin3.htm
SET currUrl EVAL("({{!LOOP}} == 1) ? '{{locUrl}}' : 'javascript:void(0);';")
URL GOTO={{currUrl}}

TAG POS={{!LOOP}} TYPE=INPUT:SUBMIT FORM=ACTION:a2.php ATTR=NAME:Submitbutton
WAIT SECONDS=1
TAG POS=1 TYPE=BODY ATTR=TXT:*OK*
BACK
I think the idea is clear.
tonnyb01
Posts: 9
Joined: Wed Aug 10, 2016 2:22 pm

Re: Using tab Buttons on an HTML page - timeout

Post by tonnyb01 » Thu Aug 11, 2016 4:59 pm

Thanks or replying. Your help is appreciated.

I tried to run the code in the first panel exactly as you wrote it and got

RuntimeError: element INPUT specified by NAME:Submitbutton was not found, line: 5

Anthony
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Using tab Buttons on an HTML page - timeout

Post by iimfun » Fri Aug 12, 2016 8:27 am

Does the following code work fine in usual mode?

Code: Select all

SET locUrl http://localhost/asin3.htm
SET currUrl EVAL("({{!LOOP}} == 1) ? '{{locUrl}}' : 'javascript:void(0);';")
URL GOTO={{currUrl}}

TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:a2.php ATTR=NAME:Submitbutton EXTRACT=TXT
TAG POS=2 TYPE=INPUT:SUBMIT FORM=ACTION:a2.php ATTR=NAME:Submitbutton EXTRACT=TXT
TAG POS=3 TYPE=INPUT:SUBMIT FORM=ACTION:a2.php ATTR=NAME:Submitbutton EXTRACT=TXT
tonnyb01
Posts: 9
Joined: Wed Aug 10, 2016 2:22 pm

Re: Using tab Buttons on an HTML page - timeout

Post by tonnyb01 » Fri Aug 12, 2016 9:57 am

This code works fine. It extracts the name of the button called by TAG POS = command.
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Using tab Buttons on an HTML page - timeout

Post by iimfun » Fri Aug 12, 2016 12:37 pm

OK. And what about this macro played both in usual and loop modes?

Code: Select all

SET locUrl http://localhost/asin3.htm
SET currUrl EVAL("({{!LOOP}} == 1) ? '{{locUrl}}' : 'javascript:void(0);';")
URL GOTO={{currUrl}}

TAG POS={{!LOOP}} TYPE=INPUT:SUBMIT FORM=ACTION:a2.php ATTR=NAME:Submitbutton EXTRACT=TXT
tonnyb01
Posts: 9
Joined: Wed Aug 10, 2016 2:22 pm

Re: Using tab Buttons on an HTML page - timeout

Post by tonnyb01 » Sun Aug 14, 2016 11:19 am

I get the looping but it doesn't extract the text. I get #EANF# each time instead of the button "txt." In fact the loop's command to extract the text times out and then repeatedly present the extract box with #EANF#.
tonnyb01
Posts: 9
Joined: Wed Aug 10, 2016 2:22 pm

Re: Using tab Buttons on an HTML page - timeout

Post by tonnyb01 » Sun Aug 14, 2016 11:19 am

I really appreciate you taking the time to help me with this.
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Using tab Buttons on an HTML page - timeout

Post by iimfun » Mon Aug 15, 2016 9:29 am

The last code must work and I can't guess what may be wrong. However the loop problem wasn't your main issue. What d'you think about the idea from the 2nd part of my first post here?
Post Reply