Selenium::Waiter(3)
πΈ Selenium::Waiter(3) β the wait_until bestie page πΈ
okay so this is Selenium::Waiter(3), a User Contributed Perl Documentation page, and it is literally the module that hands you the utility wait_until function. Version 1.49. periodt π
β¨ NAME β¨
Selenium::Waiter β Provides a utility wait_until function. That is the whole name section, and honestly it ate. π«Ά
π¦ VERSION π¦
version 1.49
π SYNOPSIS π
bestie, the vibe is:
use Selenium::Waiter qw/wait_until/;
my $d = Selenium::Remote::Driver->new;
my $div = wait_until { $d->find_element('div', 'css') };
π FUNCTIONS π
π« wait_until π«
Exported by default, wait_until takes a BLOCK (required) and optionally a hash of configuration params. It uses a prototype to take its arguments, so usage looks look like:
use Selenium::Waiter;
my $div = wait_until { $driver->find_element('div', 'css') };
The above snippet will search for "css=div" for thirty seconds; if it ever finds the element, it will immediately return. More generally, once the BLOCK returns anything truthy, wait_until will stop evaluating and the return of the BLOCK will be returned to you. If the BLOCK never returns a truthy value, we'll wait until the elapsed time has increased past the timeout and then return an empty string ''.
Achtung! Please make sure that theBLOCKyou pass in can be executed in a timely fashion. For Webdriver, that means you should set the appropriateimplicit_waittimeout low (a second or less!) so that we can rerun the assert sub repeatedly. We don't do anything fancy behind the scenes: we just execute theBLOCKyou pass in and sleep between iterations. If yourBLOCKactively blocks for thirty seconds, like afind_elementwould do with animplicit_waitof 30 seconds, we won't be able to help you at all β that blocking behavior is on the webdriver server side, and is out of our control. We'd run one iteration, get blocked for thirty seconds, and return control to you at that point.
π Dying π
PLEASE check the return value before proceeding, as we unwisely suppress any attempts your BLOCK may make to die or croak. The BLOCK you pass is called in a try in Try::Tiny, and if any of the invocations of your function throw and the BLOCK never becomes true, we'll carp exactly once at the end immediately before returning false. We overwrite the death message from each iteration, so at the end, you'll only see the most recent death message.
# warns once after thirty seconds: "kept from dying";
wait_until { die 'kept from dying' };
The output of dies from each iteration can be exposed if you wish to see the massacre:
# carps: "kept from dying" once a second for thirty seconds
wait_until { die 'kept from dying' } debug => 1;
If you want to die anyways, just pass die => 1 to wait_until instead:
# Dies on the first failure, do your own error handling:
wait_until { die 'oops' } die => 1;
β±οΈ Timeouts and Intervals β±οΈ
You can also customize the timeout, and/or the retry interval between iterations.
# prints hi three four times at 0, 3, 6, and 9 seconds
wait_until { print 'hi'; '' } timeout => 10, interval => 3;
π AUTHORS π
Current Maintainers:
- George S. Baugh <george@troglodyne.net>
Previous maintainers:
- Daniel Gempesaw <gempesaw@gmail.com>
- Emmanuel PeroumalnaΓ―k <peroumalnaik.emmanuel@gmail.com>
- Luke Closs <cpan@5thplane.com>
- Mark Stosberg <mark@stosberg.com>
Original authors:
- Aditya Ivaturi <ivaturi@gmail.com>
π COPYRIGHT AND LICENSE π
Copyright (c) 2010-2011 Aditya Ivaturi, Gordon Child
Copyright (c) 2014-2017 Daniel Gempesaw
Copyright (c) 2018-2021 George S. Baugh
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
okay bye bestie! this was Selenium::Waiter(3), generated from perl v5.42.0 on 2023-04-07 β stay patient, check your return values, and slay π
β¨π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Selenium-Remote-Driver 1.49-bp160.1.4 Β· Apache-2.0
- opensuse-leap 16.0: perl-Selenium-Remote-Driver 1.49-bp160.1.4 Β· Apache-2.0
- opensuse-leap 16.0: perl-Selenium-Remote-Driver 1.49-bp160.1.4 Β· Apache-2.0
- opensuse-leap 16.0: perl-Selenium-Remote-Driver 1.49-bp160.1.4 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms