TT#56376 selenium: backport move_and_click function from master

move_and_click automatically moves the pointer to the location and tries to
click it. It is also covered in a try/catch block, so it wont crash if
something goes wrong. Should FINALLY fix fraud limits crashes.

Change-Id: I312cc19aab5d58d3be92aa6cb80fb3e735ac371a
(cherry picked from commit 6e433734db)
changes/26/29726/1
Nico Schedel 7 years ago
parent 318ecb62af
commit e14ac51c55

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

@ -68,10 +68,9 @@ diag("Check if successful");
$d->find_element('//div[contains(@class,"accordion-body")]//table//td[contains(text(),"Sipwise")]');
diag("Edit Fraud Limits");
$d->scroll_to_element($d->find_element('//div[contains(@class,"accordion-heading")]//a[contains(text(),"Fraud Limits")]'));
$d->find_element('//div[contains(@class,"accordion-heading")]//a[contains(text(),"Fraud Limits")]')->click();
$d->move_action(element => $d->find_element('//*[@id="collapse_fraud"]/div/table/tbody/tr[1]/td//a[text()[contains(.,"Edit")]]'));
$d->find_element('//*[@id="collapse_fraud"]/div/table/tbody/tr[1]/td//a[text()[contains(.,"Edit")]]')->click();
$d->scroll_to_element($d->find_element('//div[contains(@class,"accordion-heading")]//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');
diag("Do Edit Fraud Limits");
$d->fill_element('#fraud_interval_limit', 'css', "100");

Loading…
Cancel
Save