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
changes/81/29781/5
Nico Schedel 6 years ago
parent 8ee59edae6
commit 2f5b3771a1

@ -110,7 +110,7 @@ sub wait_for_text {
} }
sub move_and_click { sub move_and_click {
my ($self, $path, $type, $timeout) = @_; my ($self, $path, $type, $fallback, $timeout) = @_;
return unless $path && $type; return unless $path && $type;
$timeout = 5 unless $timeout; # seconds. Default timeout value if none is specified. $timeout = 5 unless $timeout; # seconds. Default timeout value if none is specified.
my $started = time(); my $started = time();
@ -118,6 +118,9 @@ sub move_and_click {
while ($elapsed - $started <= $timeout){ while ($elapsed - $started <= $timeout){
$elapsed = time(); $elapsed = time();
try{ try{
if($fallback) {
$self->move_action(element => $self->find_element($fallback, $type));
}
$self->move_action(element => $self->find_element($path, $type)); $self->move_action(element => $self->find_element($path, $type));
$self->find_element($path, $type)->click(); $self->find_element($path, $type)->click();
return 1; return 1;

@ -81,7 +81,7 @@ ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contain
diag("Edit Fraud Limits"); diag("Edit Fraud Limits");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Fraud Limits")]')->click(); $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->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_limit', 'css', "100");
$d->fill_element('#fraud_interval_notify', 'css', 'mymail@example.org'); $d->fill_element('#fraud_interval_notify', 'css', 'mymail@example.org');
$d->find_element('#save', 'css')->click(); $d->find_element('#save', 'css')->click();

Loading…
Cancel
Save