Lines 114-130
sub opac_auth {
Link Here
|
114 |
sub fill_form { |
114 |
sub fill_form { |
115 |
my ( $self, $values ) = @_; |
115 |
my ( $self, $values ) = @_; |
116 |
while ( my ( $id, $value ) = each %$values ) { |
116 |
while ( my ( $id, $value ) = each %$values ) { |
117 |
my $attr = 'id'; |
117 |
my $attr = 'id'; |
118 |
my $attr_value = $id; |
118 |
my $attr_value = $id; |
119 |
if ( $id =~ m{=} ) { |
119 |
if ( $id =~ m{=} ) { |
120 |
($attr, $attr_value) = split '=', $id; |
120 |
( $attr, $attr_value ) = split '=', $id; |
121 |
} |
121 |
} |
122 |
my $element = $self->driver->find_element(sprintf '//*[@%s="%s"]', $attr, $attr_value); |
122 |
my $element = $self->driver->find_element( sprintf '//*[@%s="%s"]', $attr, $attr_value ); |
123 |
my $tag = $element->get_tag_name(); |
123 |
my $tag = $element->get_tag_name(); |
124 |
if ( $tag eq 'input' ) { |
124 |
if ( $tag eq 'input' ) { |
125 |
$self->driver->find_element(sprintf '//input[@%s="%s"]', $attr, $attr_value)->send_keys($value); |
125 |
$self->driver->find_element( sprintf '//input[@%s="%s"]', $attr, $attr_value )->send_keys($value); |
126 |
} elsif ( $tag eq 'select' ) { |
126 |
} elsif ( $tag eq 'select' ) { |
127 |
$self->driver->find_element(sprintf '//select[@%s="%s"]//option[@value="%s"]', $attr, $attr_value, $value)->click; |
127 |
$self->driver->find_element( sprintf '//select[@%s="%s"]//option[@value="%s"]', $attr, $attr_value, $value ) |
|
|
128 |
->click; |
128 |
} |
129 |
} |
129 |
} |
130 |
} |
130 |
} |
131 |
} |
Lines 201-212
sub wait_for_element_visible {
Link Here
|
201 |
sub wait_for_element_hidden { |
202 |
sub wait_for_element_hidden { |
202 |
my ( $self, $xpath_selector ) = @_; |
203 |
my ( $self, $xpath_selector ) = @_; |
203 |
|
204 |
|
204 |
my ($hidden, $elt); |
205 |
my ( $hidden, $elt ); |
205 |
$self->remove_error_handler; |
206 |
$self->remove_error_handler; |
206 |
my $max_retries = $self->max_retries; |
207 |
my $max_retries = $self->max_retries; |
207 |
my $i; |
208 |
my $i; |
208 |
while ( not $hidden ) { |
209 |
while ( not $hidden ) { |
209 |
$elt = eval {$self->driver->find_element($xpath_selector) }; |
210 |
$elt = eval { $self->driver->find_element($xpath_selector) }; |
210 |
$hidden = $elt || !$elt->is_displayed; |
211 |
$hidden = $elt || !$elt->is_displayed; |
211 |
$self->driver->pause(1000) unless $hidden; |
212 |
$self->driver->pause(1000) unless $hidden; |
212 |
|
213 |
|
Lines 351-363
when we use automation test using Selenium
Link Here
|
351 |
|
352 |
|
352 |
=head2 click |
353 |
=head2 click |
353 |
|
354 |
|
354 |
$s->click |
355 |
$s->click($xpath_selector); |
355 |
|
356 |
|
356 |
This is a bit dirty for now but will evolve depending on the needs |
357 |
This is a bit dirty for now but will evolve depending on the needs |
357 |
3 parameters possible but only the following 2 forms are used: |
358 |
3 parameters possible but only the following 2 forms are used: |
358 |
$s->click({ href => '/module/script.pl?foo=bar', main => 'doc3' }); # Sometimes we have doc or doc3. To make sure we are not going to hit a link in the header |
359 |
$s->click({ href => '/module/script.pl?foo=bar', main => 'doc3' }); # Sometimes we have doc or doc3. To make sure we are not going to hit a link in the header |
359 |
$s->click({ id => 'element_id }); |
360 |
$s->click({ id => 'element_id }); |
360 |
|
361 |
|
|
|
362 |
=head2 wait_for_element_visible |
363 |
|
364 |
$s->wait_for_element_visible($xpath_selector) |
365 |
|
366 |
Wait 10s for an element to be visible |
367 |
|
368 |
=head2 wait_for_element_hidden |
369 |
|
370 |
$s->wait_for_element_hidden($xpath_selector) |
371 |
|
372 |
Wait 10s for an element to be hidden |
373 |
|
374 |
=head2 wait_for_ajax |
375 |
|
376 |
$s->wait_for_ajax; |
377 |
|
378 |
Wait 10s for all the current AJAX requests to be received. |
379 |
|
380 |
=head2 get_next_alert_text |
381 |
|
382 |
$s->get_next_alert_text; |
383 |
|
384 |
Retrieve the next alert text. |
385 |
|
386 |
=head2 show_all_entries |
387 |
|
388 |
$s->show_all_entries($xpath_selector); |
389 |
|
390 |
Select the "All" entries of the DataTables present in the selector. |
391 |
|
361 |
=head2 click_when_visible |
392 |
=head2 click_when_visible |
362 |
|
393 |
|
363 |
$c->click_when_visible |
394 |
$c->click_when_visible |
364 |
- |
|
|