how to add wait for a text to appear

2,285 views
Skip to first unread message

henbom rina

unread,
Mar 14, 2011, 4:31:35 AM3/14/11
to seleniu...@googlegroups.com
Hi all,

I am using selenium IDE. I want to test that confirmation text or
validation text that appears on the page. Basically this text appears
after I perform a submit operation.
What I have done is for button I have given the clickAndWait command.
So I want to wait for text to appear and check the text. I have tried
using waitforpagetoload but it is not working.

Scal

unread,
Mar 14, 2011, 10:58:10 AM3/14/11
to Selenium Users
Hi;
if you use clickAndWait (in IDE) that will require waitforpagetoload
for RC since the clickAndWait() command translates into click() for
RC.

Now, your application might dynamically display the text you wait for
via some javascript function, which does not actually post the form
when you click the button.
If this is the case, you need to simply click the button and wait for
the text to be present in the page, you can use the isTextPresent()
method.
Note that you need to implement (unless you convert from IDE to your
programing language of choice) a loop with a timeout to allow Se RC to
wait for the text to actually get into the page.

Example of timeout loop in JAVA:
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (selenium.isTextPresent("Text you need to check is
present in the page")) break; } catch (Exception e) {}
Thread.sleep(1000);
}

Cheers;

mam_p

unread,
Mar 14, 2011, 5:54:17 PM3/14/11
to Selenium Users

You need IDE's waitForTextPresent if the text can be present anywhere
on the page, or IDE's waitForText if you want to specify a locator of
the element where the text must appear.

--mam-p
http://maryannmp.wordpress.com
Reply all
Reply to author
Forward
0 new messages