TT#56376 selenium: add move_and_click function

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 and call
forward crashes.

Change-Id: I50e8b8f4f46b31afbd82f66842bf4f3cda966b77
changes/16/29716/2
Nico Schedel 7 years ago
parent 2a0f51a4c6
commit ce3877d694

@ -109,4 +109,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;

@ -69,8 +69,7 @@ $d->find_element('//div[contains(@class,"accordion-body")]//table//td[contains(t
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_action(element => $d->find_element('//*[@id="collapse_fraud"]//table//tr//td[text()[contains(.,"Monthly Settings")]]/../td//a[text()[contains(.,"Edit")]]'));
$d->find_element('//*[@id="collapse_fraud"]//table//tr//td[text()[contains(.,"Monthly Settings")]]/../td//a[text()[contains(.,"Edit")]]')->click();
$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");

@ -85,8 +85,7 @@ $d->find_element("Preferences", 'link_text')->click();
diag('Trying to add a simple call forward');
$d->find_element("Call Forwards", 'link_text')->click();
$d->move_action(element => $d->find_element('//*[@id="preferences_table_cf"]/tbody/tr/td[contains(text(), "Unconditional")]/../td/div/a[contains(text(), "Edit")]'));
$d->find_element('//*[@id="preferences_table_cf"]/tbody/tr/td[contains(text(), "Unconditional")]/../td/div/a[contains(text(), "Edit")]')->click();
$d->move_and_click('//*[@id="preferences_table_cf"]/tbody/tr/td[contains(text(), "Unconditional")]/../td/div/a[contains(text(), "Edit")]', 'xpath');
$d->fill_element('//*[@id="destination.uri.destination"]', 'xpath', '43123456789');
$d->find_element('//*[@id="cf_actions.advanced"]')->click();

Loading…
Cancel
Save