Wait: "top frame is completely loaded" and ajaxy sites

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
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
mtlpatente
Posts: 4
Joined: Fri Sep 12, 2014 10:21 am

Wait: "top frame is completely loaded" and ajaxy sites

Post by mtlpatente » Thu Oct 02, 2014 2:14 pm

TAG 2 opens even though TAG 1 is not finished. So far as I understand, the WAIT default TAGS is that Imacros looks to see if the top frame is loaded, and if it is, then it moves on.
Problem is that with most websites, the top frame never changes (especially for Ajaxy sites).

Is there a way to change that default so that Imacros moves to the next TAB when the TAB is done (you see a lot of this with drop-down menus where it takes time for the site to accept the answer) and not based on the variations in the top frame.

I have used all kinds WAIT commands and none work since the website I'm using can sometimes take 1 second to accept my answer and sometimes might take up to 90 seconds. So using form-filling, which works great, is impossible as one form can take up to 1 hour since I have to delay every tab.

Glenn
skippyto
Posts: 108
Joined: Wed Aug 20, 2008 8:14 am

Re: Wait: "top frame is completely loaded" and ajaxy sites

Post by skippyto » Fri Oct 03, 2014 6:15 am

Hi mtlpatente,

You can play with the !TIMEOUT_STEP parameter (http://wiki.imacros.net/!TIMEOUT_STEP) to set the time you want to wait for an ajax element.

For example,

Code: Select all

' Set the macro's global timeout in seconds. If the macro is not completed by that time, it will exit with an error.
' Exit with error if macro takes longer that XX seconds
SET !TIMEOUT_MACRO 70

' Exit with error, if page load takes longer than XX seconds
'(Set the page load timeout in seconds. If the page is not loaded completed by that time, the macro will exit with an error. This is the successor of !TIMEOUT.)
SET !TIMEOUT_PAGE 60

' Exit with error if TAG is not found after XX seconds
'(This parameter sets the timeout in seconds for commands like TAG, IMAGESEARCH and IMAGECLICK.)
' If the corresponding HTML element or image is not found within that interval, the macro will exit with an error.
' Adjust the wait time if dealing with tricky AJAX pages, where elements can appear after a while without triggering a page reload.)
SET !TIMEOUT_STEP 1

URL GOTO=https://{{myURL}}

' FIND a basic HTML TAG 
TAG POS=1 TYPE=INPUT:IMAGE FORM=ID:"*" ATTR=TITLE:"*"

' FIND an ajax TAG and waiting for it to appear 90 seconds
SET !TIMEOUT_STEP 90
TAG POS=1 TYPE=DIV ATTR=ID:"{{myAjaxEltId}}"&&TXT:"*"
SET !TIMEOUT_STEP 1

' [...]

Skippyto
mtlpatente
Posts: 4
Joined: Fri Sep 12, 2014 10:21 am

Re: Wait: "top frame is completely loaded" and ajaxy sites

Post by mtlpatente » Sat Oct 04, 2014 12:34 pm

Thank skippyto for your quick response. Unfortunately it did not work
I wish I could share the website with you, but it is not in the public domain

This said, here is an example
2 tags, the first one opens a new case and the second tag opens Page B of that new case. But in order for the B side to load, the new case has to load first, and none of the following combinations work. In order words, imacros loads TAG A and immediately loads TAG B, without waiting for TAG A to be completed

COMBINATION 1

'Note TAG A'
SET !TIMEOUT_STEP 120
TAG POS=1 TYPE=A ATTR=ID:j_id_jsp_2010112101_3:j_id_jsp_2010112101_48
SET !TIMEOUT_STEP 1

'Note TAG B'
SET !TIMEOUT_STEP 120
TAG POS=1 TYPE=SPAN FORM=NAME:j_id_jsp_2010112101_3 ATTR=TXT:Form<SP>B
SET !TIMEOUT_STEP 1


COMBINATION 2

'Note TAG A'
TAG POS=1 TYPE=A ATTR=ID:j_id_jsp_2010112101_3:j_id_jsp_2010112101_48
SET !TIMEOUT_STEP 120

'Note TAG B'
TAG POS=1 TYPE=SPAN FORM=NAME:j_id_jsp_2010112101_3 ATTR=TXT:Form<SP>B
SET !TIMEOUT_STEP 120

Thank you
Glenn
chivracq
Posts: 8792
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Wait: "top frame is completely loaded" and ajaxy sites

Post by chivracq » Sat Oct 04, 2014 1:01 pm

CIM...! :mrgreen: (Mention your Full Config Info if you want some Answer from me...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
mtlpatente
Posts: 4
Joined: Fri Sep 12, 2014 10:21 am

Re: Wait: "top frame is completely loaded" and ajaxy sites

Post by mtlpatente » Sat Oct 04, 2014 3:37 pm

CIM : Firefox 32.0, Imacros 8.8.2, on Windows 7 (Home Premium)

Hope this is what you meant

Glenn
chivracq
Posts: 8792
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Wait: "top frame is completely loaded" and ajaxy sites

Post by chivracq » Sat Oct 04, 2014 4:18 pm

mtlpatente wrote:CIM : Firefox 32.0, Imacros 8.8.2, on Windows 7 (Home Premium)

Hope this is what you meant

Glenn
Yep, perfect... (Always mention it when you open a new Thread...)
skippyto wrote:Hi mtlpatente,

You can play with the !TIMEOUT_STEP parameter (http://wiki.imacros.net/!TIMEOUT_STEP) to set the time you want to wait for an ajax element.

For example,

Code: Select all

' Set the macro's global timeout in seconds. If the macro is not completed by that time, it will exit with an error.
' Exit with error if macro takes longer that XX seconds
SET !TIMEOUT_MACRO 70

' Exit with error, if page load takes longer than XX seconds
'(Set the page load timeout in seconds. If the page is not loaded completed by that time, the macro will exit with an error. This is the successor of !TIMEOUT.)
SET !TIMEOUT_PAGE 60

' Exit with error if TAG is not found after XX seconds
'(This parameter sets the timeout in seconds for commands like TAG, IMAGESEARCH and IMAGECLICK.)
' If the corresponding HTML element or image is not found within that interval, the macro will exit with an error.
' Adjust the wait time if dealing with tricky AJAX pages, where elements can appear after a while without triggering a page reload.)
SET !TIMEOUT_STEP 1

URL GOTO=https://{{myURL}}

' FIND a basic HTML TAG 
TAG POS=1 TYPE=INPUT:IMAGE FORM=ID:"*" ATTR=TITLE:"*"

' FIND an ajax TAG and waiting for it to appear 90 seconds
SET !TIMEOUT_STEP 90
TAG POS=1 TYPE=DIV ATTR=ID:"{{myAjaxEltId}}"&&TXT:"*"
SET !TIMEOUT_STEP 1

' [...]

Skippyto
Interesting (and impressive) Template, I must say... It's the first time I see sbd using a nice and well documented Template with iMacros... :D

For your Problem, 'mtlpatente', yep, like 'Skippyto', I would say to play with the different !TIMEOUT_* Settings, or even with a hard WAIT Statement to allow TAG 2 to load completely...

But you could try a few other things: You are "lucky" to be using Firefox, then you could try using the EVENT Mode which usually works best with Ajaxxy Pages (and is a bit slower than the "Standard" Mode(s) as it emulates the Click and Type Behaviour of a User...).
What often works well on triky Pages is to use the EVENT Mode, then click/select/tag some HTML Element very close from the Element you'll actually want to interact with and "navigate" to that Element using the Keyboard Tab and Arrow Keys (instead of the Mouse).

Another Trick would be (in Normal or in EVENT Mode), to try to tag another HTML Element that would appear indicating that TAG 2 has finished loading before really clicking on TAG 2, allowing you to play with !TIMEOUT_STEP.
In Normal Mode, you can use "EXTRACT=TXT" to prevent iMacros from actually really clicking on that intermediary Element if it's a real Button or a Hyperlink. And you could even add some Conditional WAIT based on the Extract using 'EVAL()'...

See this Thread and all referenced Threads in it for more Info and Tricks on the EVENT Mode, that's all I can do for you without being able to play with the Page...:
- Re: Feedback and Issues on EVENT Recording Mode.
.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
mtlpatente
Posts: 4
Joined: Fri Sep 12, 2014 10:21 am

Re: Wait: "top frame is completely loaded" and ajaxy sites

Post by mtlpatente » Sat Oct 04, 2014 8:17 pm

Event mode is amazing, just discovered it about 2 months ago and made everything way easier, like letting the macro run and being able to work on the computer
Extract is a good solution, and it has helped.
WAIT definitely is the best solution, but with so many variables to upload, adding a WAIT SECONDS=90 every step makes uploading several cases using, a CSV file, a never ending task, and you`re screwed if one TAG takes more than 90 seconds

mouseWaitIcon
This may be impossible, but is there a way to have Imacros record and wait for the wait icon to be done (those icons that appear when a website is waiting, like an hour glass or a spinning wheel, like the one you see here http://www.ca.kayak.com/s/compareresult ... ype=hotelss )

If this helps, the Ajax code (God these codes are awful), from my website, that generates the wait icon is : <img id="mouseWaitIcon" alt="Waiting/attente" class="ajaxLoadingImage" style="position: absolute; z-index: 1000; border: 0px none; padding: 0px; margin: 0px; left: 700px; top: 1767px; display: none;" src="/baseUI/images/activityIndicators/circly_transp.gif">

Anyhow, using EVENT and EXTRACT has greatly improved the Imacros, so thank you for that tip.
Glenn
chivracq
Posts: 8792
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Wait: "top frame is completely loaded" and ajaxy sites

Post by chivracq » Sun Oct 05, 2014 1:38 pm

OK, if the 'mouseWaitIcon' Element is the Indicator that TAG 2 has not finished loading, then you can put a few "Conditional WAIT" Statements based on "EXTRACT=TXT (or =TITLE)" before to split the 90 sec into several Chunks (and even extend it to 180 sec, just to be sure).
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply