Lines 56-67
sub add_error_handler {
Link Here
|
56 |
$self->{driver}->error_handler( |
56 |
$self->{driver}->error_handler( |
57 |
sub { |
57 |
sub { |
58 |
my ( $driver, $selenium_error ) = @_; |
58 |
my ( $driver, $selenium_error ) = @_; |
59 |
print STDERR "\nSTRACE:"; |
59 |
$self->_print_stack_trace; |
60 |
my $i = 1; |
|
|
61 |
while ( (my @call_details = (caller($i++))) ){ |
62 |
print STDERR "\t" . $call_details[1]. ":" . $call_details[2] . " in " . $call_details[3]."\n"; |
63 |
} |
64 |
print STDERR "\n"; |
65 |
$self->capture( $driver ); |
60 |
$self->capture( $driver ); |
66 |
$driver->quit(); |
61 |
$driver->quit(); |
67 |
croak $selenium_error; |
62 |
croak $selenium_error; |
Lines 194-210
sub wait_for_element_visible {
Link Here
|
194 |
} |
189 |
} |
195 |
|
190 |
|
196 |
sub wait_for_ajax { |
191 |
sub wait_for_ajax { |
197 |
my ( $self ) = @_; |
192 |
my ( $self, $max_retries ) = @_; |
198 |
|
193 |
|
199 |
my $is_ready; |
194 |
my $is_ready; |
200 |
my $max_retries = $self->max_retries; |
195 |
$max_retries ||= $self->max_retries; |
201 |
my $i; |
196 |
my $i; |
|
|
197 |
$is_ready = $self->driver->execute_script('return jQuery.active == 0'); |
202 |
while ( not $is_ready ) { |
198 |
while ( not $is_ready ) { |
203 |
$is_ready = $self->driver->execute_script('return jQuery.active == 0'); |
199 |
$is_ready = $self->driver->execute_script('return jQuery.active == 0'); |
204 |
$self->driver->pause(1000) unless $is_ready; |
200 |
$self->driver->pause(1000) unless $is_ready; |
205 |
|
201 |
|
206 |
die "Cannot wait more for jQuery to be active (wait_for_ajax)" |
202 |
if ( $max_retries <= ++$i ) { |
207 |
if $max_retries <= ++$i |
203 |
$self->capture( $self->driver ); |
|
|
204 |
$self->_print_stack_trace; |
205 |
$self->driver->quit(); |
206 |
die "Cannot wait more for jQuery to be active (wait_for_ajax)"; |
207 |
} |
208 |
} |
208 |
} |
209 |
} |
209 |
} |
210 |
|
210 |
|
Lines 267-272
sub click_when_visible {
Link Here
|
267 |
|
267 |
|
268 |
sub max_retries { 10 } |
268 |
sub max_retries { 10 } |
269 |
|
269 |
|
|
|
270 |
sub _print_stack_trace { |
271 |
print STDERR "\nSTRACE:"; |
272 |
my $i = 1; |
273 |
while ( ( my @call_details = ( caller( $i++ ) ) ) ) { |
274 |
print STDERR "\t" . $call_details[1] . ":" . $call_details[2] . " in " . $call_details[3] . "\n"; |
275 |
} |
276 |
print STDERR "\n"; |
277 |
} |
278 |
|
279 |
|
270 |
=head1 NAME |
280 |
=head1 NAME |
271 |
|
281 |
|
272 |
t::lib::Selenium - Selenium helper module |
282 |
t::lib::Selenium - Selenium helper module |
Lines 358-363
It will remove any kinds of error raised by the driver.
Link Here
|
358 |
It can be useful in some cases, for instance if you want to make sure something will not happen and that could make the driver exploses otherwise. |
368 |
It can be useful in some cases, for instance if you want to make sure something will not happen and that could make the driver exploses otherwise. |
359 |
You certainly should call it for only one statement then must call add_error_handler right after. |
369 |
You certainly should call it for only one statement then must call add_error_handler right after. |
360 |
|
370 |
|
|
|
371 |
=head2 wait_for_ajax |
372 |
|
373 |
Wait until all XHR requests are finished. Timeouts after |
374 |
$self->max_retries attempts. (ajustable by optional argument) |
375 |
|
361 |
=head1 AUTHORS |
376 |
=head1 AUTHORS |
362 |
|
377 |
|
363 |
Jonathan Druart <jonathan.druart@bugs.koha-community.org> |
378 |
Jonathan Druart <jonathan.druart@bugs.koha-community.org> |
364 |
- |
|
|