Bug 26162: Wait for the table to be refreshed
The previous patch did not work as expected. We still got a
StaleElementReference exception.
But this time on
10:43:47 selenium_1 | Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//*[@id=\"branchname\"]"}
Because we found the one that existed on the page, not the one sent back
in AJAX.
The idea of this patch is to search for the "Showing 1 to X of Y entries" info and wait for X == Y
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 70ff3bafa0)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit ce8a819b5f)
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
(cherry picked from commit 0a127a78e9)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
parent
4a3f41a618
commit
fba2a862a3
|
|
@ -166,15 +166,44 @@ sub click {
|
|||
$self->click_when_visible( $xpath_selector );
|
||||
}
|
||||
|
||||
sub click_when_visible {
|
||||
sub wait_for_element_visible {
|
||||
my ( $self, $xpath_selector ) = @_;
|
||||
|
||||
$self->driver->set_implicit_wait_timeout(20000);
|
||||
my ($visible, $elt);
|
||||
$self->remove_error_handler;
|
||||
while ( not $visible ) {
|
||||
$elt = eval {$self->driver->find_element($xpath_selector) };
|
||||
$visible = $elt && $elt->is_displayed;
|
||||
$self->driver->pause(1000) unless $visible;
|
||||
}
|
||||
$self->add_error_handler;
|
||||
return $elt;
|
||||
}
|
||||
|
||||
sub show_all_entries {
|
||||
my ( $self, $xpath_selector ) = @_;
|
||||
|
||||
$self->driver->find_element( $xpath_selector
|
||||
. '//div[@class="dataTables_length"]/label/select/option[@value="-1"]'
|
||||
)->click;
|
||||
my ($all_displayed);
|
||||
while ( not $all_displayed ) {
|
||||
my $dt_infos = $self->driver->get_text(
|
||||
$xpath_selector . '//div[@class="dataTables_info"]' );
|
||||
|
||||
if ( $dt_infos =~ m|Showing 1 to (\d+) of (\d+) entries| ) {
|
||||
$all_displayed = 1 if $1 == $2;
|
||||
}
|
||||
|
||||
$self->driver->pause(1000) unless $all_displayed;
|
||||
}
|
||||
}
|
||||
|
||||
sub click_when_visible {
|
||||
my ( $self, $xpath_selector ) = @_;
|
||||
|
||||
my $elt = $self->wait_for_element_visible( $xpath_selector );
|
||||
|
||||
my $clicked;
|
||||
$self->remove_error_handler;
|
||||
|
|
|
|||
Loading…
Reference in New Issue