TT#56376 selenium: controller_billing.t code cleanups

controller_billing.t:
- Made garbage search call much simpler.
- Replace find_element with find_element_by_css, prevents crashing if
garbage text search didnt work.
- Added new ok() tests for find_element_by_css.
- Removed commented lines

Change-Id: I42cf670c47cdc22db9ba1c8079fac3e3bb5147c8
changes/81/29081/5
Nico Schedel 7 years ago
parent cf0e3b87b8
commit da24a58196

@ -32,31 +32,19 @@ $d->find_element('//select[@id="fraud_interval_lock"]/option[contains(text(),"fo
$d->find_element('//div[contains(@class,"modal")]//input[@type="submit"]')->click();
diag("Search nonexisting billing profile");
my $searchfield = $d->find_element('#billing_profile_table_filter label input', 'css');
ok($searchfield);
$searchfield->send_keys('donotfindme');
diag("Verify that nothing is shown");
my $elem = $d->find_element('#billing_profile_table td.dataTables_empty', 'css');
ok($elem);
is($elem->get_text, 'No matching records found');
$d->fill_element('#billing_profile_table_filter label input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
diag('Search for "mytestprofile" in billing profile');
$searchfield->clear();
$searchfield->send_keys('mytestprofile');
#$d->find_element('#billing_profile_table tr.sw_action_row', css);
ok($d->find_element('//table[@id="billing_profile_table"]//tr[1]/td[2][contains(text(),"mytestprofile")]'));
$d->fill_element('#billing_profile_table_filter label input', 'css', 'mytestprofile');
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', 'mytestprofile'), 'Billing profile was found');
diag("Open edit dialog for mytestprofile");
my $row = $d->find_element('//table/tbody/tr/td[contains(text(), "mytestprofile")]/..');
ok($row);
my $edit_link = $d->find_child_element($row, '(./td//a)[contains(text(),"Edit")]');
ok($edit_link);
$d->move_action(element => $row);
$edit_link->click();
$d->move_action(element => $d->find_element('//table/tbody/tr/td[contains(text(), "mytestprofile")]/..'));
$d->find_child_element($d->find_element('//table/tbody/tr/td[contains(text(), "mytestprofile")]/..'), '(./td//a)[contains(text(),"Edit")]')->click();
diag("Edit mytestprofile");
$elem = $d->find_element('#name', 'css');
my $elem = $d->find_element('#name', 'css');
ok($elem);
is($elem->get_value, "mytestprofile");
$d->fill_element('#interval_charge', 'css', '3.2');
@ -64,9 +52,9 @@ $d->find_element('#save', 'css')->click();
sleep 1;
diag('Open "Fees" for mytestprofile');
$row = $d->find_element('//table/tbody/tr/td[contains(text(), "mytestprofile")]/..');
my $row = $d->find_element('//table/tbody/tr/td[contains(text(), "mytestprofile")]/..');
ok($row);
$edit_link = $d->find_child_element($row, '(./td//a)[contains(text(),"Fees")]');
my $edit_link = $d->find_child_element($row, '(./td//a)[contains(text(),"Fees")]');
ok($edit_link);
$d->move_action(element => $row,xoffset => 1);
$edit_link->click();
@ -80,7 +68,6 @@ $d->fill_element('#zone', 'css', 'testingzone');
$d->fill_element('#detail', 'css', 'testingdetail');
$d->find_element('#save', 'css')->click();
diag("Back to orignial form (create billing fees)");
#sleep 2; # give ajax time to load
$d->select_if_unselected('//div[contains(@class,"modal")]//div[contains(@class,"dataTables_wrapper")]//td[contains(text(),"testingzone")]/..//input[@type="checkbox"]');
$d->fill_element('#source', 'css', '.*');
$d->fill_element('#destination', 'css', '.+');
@ -104,7 +91,7 @@ ok($d->find_element('//*[@id="masthead"]//h2[contains(text(),"Billing Zones")]')
diag("Delete testingzone");
$d->fill_element('//div[contains(@class, "dataTables_filter")]//input', 'xpath', 'thisshouldnotexist');
$d->find_element('#billing_zone_table tr > td.dataTables_empty', 'css');
ok($d->find_element_by_css('#billing_zone_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//div[contains(@class, "dataTables_filter")]//input', 'xpath', 'testingdetail');
$row = $d->find_element('//div[contains(@class,"dataTables_wrapper")]//td[contains(text(),"testingzone")]/..');
ok($row);
@ -176,5 +163,4 @@ $d->find_element('//*[@id="date_definition_table"]/tbody/tr/td[4]/div/a[2]')->cl
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
done_testing;
# vim: filetype=perl
done_testing;
Loading…
Cancel
Save