@@ -, +, @@ --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 2 +- t/db_dependent/selenium/regressions.t | 2 ++ t/lib/Selenium.pm | 22 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -281,7 +281,7 @@ $(document).ready(function() { return false; }); console.log("show checkouts handler attached") - + window._pageFullyReady = {}; } ,2000); --- a/t/db_dependent/selenium/regressions.t +++ a/t/db_dependent/selenium/regressions.t @@ -186,6 +186,7 @@ subtest 'Display circulation table correctly' => sub { . "/circ/circulation.pl?borrowernumber=" . $patron->borrowernumber ); + $s->wait_for_page_fully_ready; # Display the table clicking on the "Show checkouts" button $driver->find_element('//a[@id="issues-table-load-now-button"]')->click; @@ -313,6 +314,7 @@ subtest 'Encoding in session variables' => sub { $driver->find_element('//input[@id="barcode"]')->send_keys( $item->barcode ); $driver->find_element('//fieldset[@id="circ_circulation_issue"]/button[@type="submit"]')->click; + $s->wait_for_page_fully_ready; # Display the table clicking on the "Show checkouts" button $driver->find_element('//a[@id="issues-table-load-now-button"]') ->click; --- a/t/lib/Selenium.pm +++ a/t/lib/Selenium.pm @@ -265,6 +265,28 @@ sub click_when_visible { $elt->click unless $clicked; # finally Raise the error } + +sub wait_for_page_fully_ready { + my ($self) = @_; + + my $is_ready; + my $max_retries = $self->max_retries; + + my $i; + while ( not $is_ready ) { + warn "############# waiting (" . $i . ")"; + $is_ready = $self->driver->execute_script('return window._pageFullyReady'); + $self->driver->pause(333) unless $is_ready; + + if ( $max_retries <= ++$i ) { + $self->capture( $self->driver ); + $self->driver->quit(); + die "Cannot wait more for page to be fully ready (wait_for_page_fully_ready)"; + } + } +} + + sub max_retries { 10 } =head1 NAME --