From 527b2b634f72b8f8025fc58b404b5022dc3eb3e9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 31 Jan 2022 16:39:59 +0100 Subject: [PATCH] Bug 29458: Fix selenium test The authentication.t selenium tests (and a couple of others) were failing with: Error while executing command: element not interactable: Element could not be scrolled into view at /usr/local/share/perl/5.32.1/Selenium/Remote/Driver.pm line 411. at /usr/local/share/perl/5.32.1/Selenium/Remote/Driver.pm line 356. We changed the other of the form, and t::lib::Selenium::submit_form was not getting the correct (first) form. The one from the auth modal was retrieved and submit button was clicked. Selenium raised an error as it is not displayed. The ->is_displayed selenium method does not work, as per the doc """ Note: This does *not* tell you an element's 'visibility' property; as it still takes up space in the DOM and is therefore considered 'displayed'. """ https://metacpan.org/pod/Selenium::Remote::WebElement#is_displayed "The internet" is saying we should be able to use the following in our xpath expression: not(ancestor::div[contains(@style,'display:none')] but it actually only works if the display:none rule is defined on the node (not from .css). Which does not work for us. The only solution I found is to check for the size of the element, which is (0,0) if not effectively displayed. Signed-off-by: Fridolin Somers (cherry picked from commit 5520b8fb84f26419c6ec9f73a14cdf14f036afce) Signed-off-by: Arthur Suzuki --- t/lib/Selenium.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/t/lib/Selenium.pm b/t/lib/Selenium.pm index b49bc730b0..6d9afacdce 100644 --- a/t/lib/Selenium.pm +++ b/t/lib/Selenium.pm @@ -135,7 +135,11 @@ sub submit_form { } my $default_submit_selector = '//fieldset[@class="action"]/input[@type="submit"]'; - $self->driver->find_element($default_submit_selector)->click + my @elts = map { my $size = $_->get_size; ( $size->{height} && $size->{width} ) ? $_ : () } $self->driver->find_elements($default_submit_selector); + + die "Too many forms are displayed. Cannot submit." if @elts > 1; + + return $elts[0]->click; } sub click { -- 2.39.5