BourneID has asked for the wisdom of the Perl Monks concerning the following question:

Good day! I am using selenium to test a PPR(Partial Page Refresh,such as Adjx) web application. I can use waitForXXX commands in Selenium IDE. However, when I use Selenium RC in perl, it can not be used directly.For example,the command "watForElementPresent("xpath=\"XXXXX\"")" cannot be directly used in perl, and must be replaced as following:
WAIT: { for (1..60) { if (eval { $sel->is_element_present("xpath=\"XXXXX\"") }) { pass; last WAIT } sleep(1); } fail("timeout"); }
So, how can use these wait for commnads in one line in perl?

Replies are listed 'Best First'.
Re: Selenium waitForXXXX in Perl
by Corion (Patriarch) on Sep 06, 2010 at 07:26 UTC

    Why not wrap these commands in a subroutine?

Re: Selenium waitForXXXX in Perl
by ikegami (Patriarch) on Sep 06, 2010 at 07:27 UTC

    So, how can use these wait for commnads in one line in perl?

    Put that code in a sub.

Re: Selenium waitForXXXX in Perl
by suhailck (Friar) on Sep 06, 2010 at 07:46 UTC
    Why dont you use

    $sel->wait_for_element_present($locator, $timeout) Waits until $locator is present $timeout is a timeout in milliseconds, after which the action will re +turn with an error. #for your example, $sel->wait_for_element_present("xpath=\"XXXXX\"",60000)


    see, WWW::Selenium