How do I wait until a string of text appears?

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
madpsintst
Posts: 2
Joined: Thu Dec 16, 2010 3:14 pm

How do I wait until a string of text appears?

Post by madpsintst » Thu Dec 16, 2010 3:25 pm

Sorry for the newbie question, but I am having trouble figuring out how to make iMacros wait for a string of text to appear. I have a script running on an online voting page. I want iMacros to wait until the text "Thanks for your vote" appears. Sometimes it takes a fraction of a second for the vote to register and the text to appear, while other times it takes as long as 20 seconds. I know I can use the WAIT SECONDS=x command using a large value for x, but this will make for very slow voting. Any suggestions are appreciated. :)
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: How do I wait until a string of text appears?

Post by siniy » Fri Dec 17, 2010 10:20 am

For such task I use extracting some text on results page.

Code: Select all

SET !TIMEOUT_TAG 10
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=DIV ATTR=TXT:Thanks* EXTRACT=TXT
madpsintst
Posts: 2
Joined: Thu Dec 16, 2010 3:14 pm

Re: How do I wait until a string of text appears?

Post by madpsintst » Sat Dec 18, 2010 2:41 pm

Thank you! It works! :D
saki
Posts: 4
Joined: Fri Mar 04, 2016 2:32 pm

Re: How do I wait until a string of text appears?

Post by saki » Fri Mar 04, 2016 2:41 pm

Hello.

I am struggling with a macro for a dynamic, javascript-heavy page, and the above technique is not working for me.

On my page, when I click some text "[ Select ]", it instantly changes to "[ Processing ]" before becoming "[ Selected ]".

After clicking "[ Select ]", I want the macro to wait until "[ Selected ]" appears before moving to the next step without using a WAIT step. The above solution sounds ideal, but I am seeing some weird behavior.

I tested that that I identified the correct POS value as follows:

Code: Select all

WAIT SECONDS=30
TAG POS=16 TYPE=TD ATTR=TXT:* EXTRACT=TXT
This was successful: the step successfully extracts "[ Selected ]"

As per the above example, I then tried to make it specific to the required text "[ Selected ]"

Code: Select all

TAG POS=16 TYPE=TD ATTR=TXT:"[ Selected ]" EXTRACT=TXT
But this fails!
It is as though it can only sometimes read what the text is.

Any suggestions on what I'm doing wrong?

I'm using FF 44.0.2 on Windows 8.1. iMacros build 8961227

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

Re: How do I wait until a string of text appears?

Post by chivracq » Fri Mar 04, 2016 4:57 pm

saki wrote:Hello.

I am struggling with a macro for a dynamic, javascript-heavy page, and the above technique is not working for me.

On my page, when I click some text "[ Select ]", it instantly changes to "[ Processing ]" before becoming "[ Selected ]".

After clicking "[ Select ]", I want the macro to wait until "[ Selected ]" appears before moving to the next step without using a WAIT step. The above solution sounds ideal, but I am seeing some weird behavior.

I tested that that I identified the correct POS value as follows:

Code: Select all

WAIT SECONDS=30
TAG POS=16 TYPE=TD ATTR=TXT:* EXTRACT=TXT
This was successful: the step successfully extracts "[ Selected ]"

As per the above example, I then tried to make it specific to the required text "[ Selected ]"

Code: Select all

TAG POS=16 TYPE=TD ATTR=TXT:"[ Selected ]" EXTRACT=TXT
But this fails!
It is as though it can only sometimes read what the text is.

Any suggestions on what I'm doing wrong?

I'm using

Code: Select all

FF 44.0.2 on Windows 8.1.  iMacros build 8961227
Thank you!
Try with:

Code: Select all

TAG POS=16 TYPE=TD ATTR=TXT:[<SP>Selected<SP>] EXTRACT=TXT
or:

Code: Select all

TAG POS=16 TYPE=TD ATTR=TXT:*[*Selected*]* EXTRACT=TXT
or even simply:

Code: Select all

TAG POS=16 TYPE=TD ATTR=TXT:*Selected* EXTRACT=TXT
Hum, and mini-Rmk:
'!TIMEOUT_TAG' is now deprecated, even if it still works, and has been replaced a few years ago already by '!TIMEOUT_STEP'...
Last edited by chivracq on Fri Mar 04, 2016 5:08 pm, edited 1 time in total.
- (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...
saki
Posts: 4
Joined: Fri Mar 04, 2016 2:32 pm

Re: How do I wait until a string of text appears?

Post by saki » Fri Mar 04, 2016 5:07 pm

Thanks chivracq.

Unfortunately I get the same problem - the #EANF# extract error.

Given I can extract "[ Selected ]" sucessfully when ATTR=TXT:* I find it very strange it's not working

Anything else I can try?
chivracq
Posts: 9575
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How do I wait until a string of text appears?

Post by chivracq » Fri Mar 04, 2016 5:13 pm

saki wrote:Thanks chivracq.

Unfortunately I get the same problem - the #EANF# extract error.

Given I can extract "[ Selected ]" sucessfully when ATTR=TXT:* I find it very strange it's not working

Anything else I can try?
Hum, strange, it should work...

Are you sure about the POS=16...? That doesn't sound very reliable, try using some Relative Positioning to lower the POS Number, and/or some other Attribute(s).
Because it is 'POS=16' with 'TXT:*', but it probably becomes 'POS=1' with 'TXT:*Selected*'...

Can you post your '!TIMEOUT_xxx' Settings...?

Can't you post the URL...?
- (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...
saki
Posts: 4
Joined: Fri Mar 04, 2016 2:32 pm

Re: How do I wait until a string of text appears?

Post by saki » Fri Mar 04, 2016 5:20 pm

Really appreciate your help on this.
I'm not hitting Timeout limits, and although POS=16 sounds odd (indeed, took me a little while to find it), it is reliable - the text is in a table that has 8 columns. POS=16 because it's the end of the second row.

It's a password protected site, but I would be happy to share with you privately if you advised the best way to get you my credentials?
chivracq
Posts: 9575
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How do I wait until a string of text appears?

Post by chivracq » Fri Mar 04, 2016 5:43 pm

saki wrote:Really appreciate your help on this.
I'm not hitting Timeout limits, and although POS=16 sounds odd (indeed, took me a little while to find it), it is reliable - the text is in a table that has 8 columns. POS=16 because it's the end of the second row.

It's a password protected site, but I would be happy to share with you privately if you advised the best way to get you my credentials?
Yep, but again;
Because it is 'POS=16' with 'TXT:*', but it probably becomes 'POS=1' with 'TXT:*Selected*'...

I would be surprised if all 16 Cells all contain the Text 'Selected'...
- (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...
saki
Posts: 4
Joined: Fri Mar 04, 2016 2:32 pm

Re: How do I wait until a string of text appears?

Post by saki » Fri Mar 04, 2016 5:56 pm

Ah ha! That works!
I thought that the POS value was static, not dependent on the text string.
So helpful! Thanks Chivracq!
chivracq
Posts: 9575
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How do I wait until a string of text appears?

Post by chivracq » Fri Mar 04, 2016 6:22 pm

saki wrote:Ah ha! That works!
I thought that the POS value was static, not dependent on the text string.
So helpful! Thanks Chivracq!
Hahan...!! Beh..., no!, all Parameters and Attributes count when locating some HTML Element, that's the "aim of the game"...!

You actually used the "Technique" with Wildcards in some odd "the other way around' way, you normally start by tagging your Element with all Attributes and it usually gets 'POS=1' but if you then use Wildcard(s) for any Parameter(s)/Attribute(s), then you often have to adjust 'POS=1' to 'POS=2 / 3 / 4 / ... / 16...!'. But you started from the other Side of the path...

OK, glad it works and that I could help you... :D
- (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