From 2f5b3771a1f42ebe02e04fb1a02a85f16e29e6af Mon Sep 17 00:00:00 2001 From: Nico Schedel Date: Mon, 13 May 2019 11:48:40 +0200 Subject: [PATCH] TT#56376 selenium: move_and_click: add optional fallback parameter FirefoxExtensions.pm: - Add optional fallback parameter. This can be used to move the mouse somewhere else before moving it to the actual location, preventing crashes if ajax messes with button visibility again. Change-Id: I300cccbcc4b99335069796f1d8f56b8fb92bb2b0 --- t/lib/Selenium/Remote/Driver/FirefoxExtensions.pm | 5 ++++- t/selenium/controller_customer.t | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/t/lib/Selenium/Remote/Driver/FirefoxExtensions.pm b/t/lib/Selenium/Remote/Driver/FirefoxExtensions.pm index c565212b64..3156f72c9b 100644 --- a/t/lib/Selenium/Remote/Driver/FirefoxExtensions.pm +++ b/t/lib/Selenium/Remote/Driver/FirefoxExtensions.pm @@ -110,7 +110,7 @@ sub wait_for_text { } sub move_and_click { - my ($self, $path, $type, $timeout) = @_; + my ($self, $path, $type, $fallback, $timeout) = @_; return unless $path && $type; $timeout = 5 unless $timeout; # seconds. Default timeout value if none is specified. my $started = time(); @@ -118,6 +118,9 @@ sub move_and_click { while ($elapsed - $started <= $timeout){ $elapsed = time(); try{ + if($fallback) { + $self->move_action(element => $self->find_element($fallback, $type)); + } $self->move_action(element => $self->find_element($path, $type)); $self->find_element($path, $type)->click(); return 1; diff --git a/t/selenium/controller_customer.t b/t/selenium/controller_customer.t index 6e7f0c6dfd..830ab60139 100644 --- a/t/selenium/controller_customer.t +++ b/t/selenium/controller_customer.t @@ -81,7 +81,7 @@ ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contain diag("Edit Fraud Limits"); $d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Fraud Limits")]')->click(); $d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Fraud Limits")]')); -$d->move_and_click('//*[@id="collapse_fraud"]//table//tr//td[text()[contains(.,"Monthly Settings")]]/../td//a[text()[contains(.,"Edit")]]', 'xpath'); +$d->move_and_click('//*[@id="collapse_fraud"]//table//tr//td[text()[contains(.,"Monthly Settings")]]/../td//a[text()[contains(.,"Edit")]]', 'xpath', '//*[@id="customer_details"]//div//a[contains(text(),"Fraud Limits")]'); $d->fill_element('#fraud_interval_limit', 'css', "100"); $d->fill_element('#fraud_interval_notify', 'css', 'mymail@example.org'); $d->find_element('#save', 'css')->click();