TT#56376 selenium: more reliable actions for invisible buttons

controller_customer.t:
- Edited code blocks around clicking invisible buttons. Should work
more reliable now.
- replaced find_element with find_element_by_css when checking for
empty tables. Should prevent crashing.

Change-Id: Ifa7e8f85a1eec17e530032660781fa5840685edd
changes/62/29162/2
Nico Schedel 7 years ago
parent fde849d53a
commit ee07bbb651

@ -62,14 +62,11 @@ $d->find_element('#save', 'css')->click();
diag("Open Details for our just created Customer"); diag("Open Details for our just created Customer");
sleep 2; #Else we might search on the previous page sleep 2; #Else we might search on the previous page
$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist'); $d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist');
$d->find_element('#Customer_table tr > td.dataTables_empty', 'css'); ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Garbage test not found');
$d->fill_element('#Customer_table_filter input', 'css', $rnd_id); $d->fill_element('#Customer_table_filter input', 'css', $rnd_id);
my $row = $d->find_element('(//table/tbody/tr/td[contains(text(), "'.$rnd_id.'")]/..)[1]'); ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $rnd_id), 'Customer found');
ok($row, 'Searching for current customer works'); $d->move_action(element=> $d->find_element('//*[@id="Customer_table"]/tbody/tr[1]/td[2]'));
my $edit_link = $d->find_child_element($row, '(./td//a)[contains(text(),"Details")]'); $d->find_element('//*[@id="Customer_table"]/tbody/tr[1]/td[10]/div/a[3]')->click();
ok($edit_link, 'Can click on Details');
$d->move_action(element => $row);
$edit_link->click();
diag("Edit our contact"); diag("Edit our contact");
$d->find_element('//div[contains(@class,"accordion-heading")]//a[contains(text(),"Contact Details")]')->click(); $d->find_element('//div[contains(@class,"accordion-heading")]//a[contains(text(),"Contact Details")]')->click();
@ -96,7 +93,7 @@ $d->find_element('//*[@id="collapse_subs"]/div/a')->click();
diag('Enter necessary information'); diag('Enter necessary information');
$d->fill_element('//*[@id="domainidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist'); $d->fill_element('//*[@id="domainidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#domainidtable tr > td.dataTables_empty', 'css'), 'Table is empty'); ok($d->find_element_by_css('#domainidtable tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="domainidtable_filter"]/label/input', 'xpath', $domainstring); $d->fill_element('//*[@id="domainidtable_filter"]/label/input', 'xpath', $domainstring);
ok($d->wait_for_text('//*[@id="domainidtable"]/tbody/tr[1]/td[3]', $domainstring), 'Domain found'); ok($d->wait_for_text('//*[@id="domainidtable"]/tbody/tr[1]/td[3]', $domainstring), 'Domain found');
$d->select_if_unselected('//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input'); $d->select_if_unselected('//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input');
@ -118,12 +115,10 @@ $d->find_element('//*[@id="subscribers_table_filter"]/label/input')->send_keys($
ok($d->wait_for_text('//*[@id="subscribers_table"]/tbody/tr/td[2]', $username), 'Subscriber was found'); ok($d->wait_for_text('//*[@id="subscribers_table"]/tbody/tr/td[2]', $username), 'Subscriber was found');
diag("Edit Fraud Limits"); diag("Edit Fraud Limits");
my $elem = $d->find_element('//div[contains(@class,"accordion-heading")]//a[contains(text(),"Fraud Limits")]'); $d->scroll_to_element($d->find_element('//div[contains(@class,"accordion-heading")]//a[contains(text(),"Fraud Limits")]'));
$d->scroll_to_element($elem); $d->find_element('//div[contains(@class,"accordion-heading")]//a[contains(text(),"Fraud Limits")]')->click();
$elem->click(); $d->move_action(element => $d->find_element('//div[contains(@class,"accordion-body")]//table//tr/td[contains(text(),"Monthly Settings")]'));
$row = $d->find_element('//div[contains(@class,"accordion-body")]//table//tr/td[contains(text(),"Monthly Settings")]'); $d->find_element('//*[@id="collapse_fraud"]/div/table/tbody/tr[1]/td[5]/div/a[1]')->click();
$d->move_action(element => $row);
$edit_link = $d->find_child_element($row, './../td//a[text()[contains(.,"Edit")]]')->click();
diag("Do Edit Fraud Limits"); diag("Do Edit Fraud Limits");
$d->fill_element('#fraud_interval_limit', 'css', "100"); $d->fill_element('#fraud_interval_limit', 'css', "100");
@ -134,14 +129,11 @@ $d->find_element('//div[contains(@class,"accordion-body")]//table//td[contains(t
diag("Terminate our customer"); diag("Terminate our customer");
$d->find_element('//a[contains(@class,"btn-primary") and text()[contains(.,"Back")]]')->click(); $d->find_element('//a[contains(@class,"btn-primary") and text()[contains(.,"Back")]]')->click();
$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist'); $d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist');
$d->find_element('#Customer_table tr > td.dataTables_empty', 'css'); ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('#Customer_table_filter input', 'css', $rnd_id); $d->fill_element('#Customer_table_filter input', 'css', $rnd_id);
$row = $d->find_element('(//table/tbody/tr/td[contains(text(), "'.$rnd_id.'")]/..)[1]'); ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $rnd_id), 'Found customer');
ok($row, 'Found customer'); $d->move_action(element => $d->find_element('//*[@id="Customer_table"]/tbody/tr[1]/td[2]'));
$edit_link = $d->find_child_element($row, '(./td//a)[contains(text(),"Terminate")]'); $d->find_element('//*[@id="Customer_table"]/tbody/tr[1]/td[10]/div/a[2]')->click();
ok($edit_link, 'Found terminate button');
$d->move_action(element => $row);
$edit_link->click();
ok($d->find_text("Are you sure?"), 'Delete dialog appears'); ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click(); $d->find_element('#dataConfirmOK', 'css')->click();
ok($d->find_text("Customer successfully terminated"), 'Text "Customer successfully terminated" appears'); ok($d->find_text("Customer successfully terminated"), 'Text "Customer successfully terminated" appears');

Loading…
Cancel
Save