TT#56376 selenium: add function: create/delete_ncos

Common.pm:
- added functions create_ncos and delete_ncos to easily create a ncos where
it is needed. will be used for a new file later

controller_ncos.t:
- replace create/delete code with new functions

Change-Id: I81a720d8a87502dcc2cfbd542226b3b82134a43b
changes/59/33559/3
Nico Schedel 6 years ago
parent 9b13357736
commit 5e919b54c9

@ -368,6 +368,50 @@ sub delete_billing_profile {
};
}
sub create_ncos {
my($self, $resellername, $ncosname) = @_;
return unless $resellername && $ncosname;
diag('Go to NCOS interface');
$self->driver->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$self->driver->find_element("NCOS Levels", 'link_text')->click();
diag('Create a NCOS');
$self->driver->find_element('Create NCOS Level', 'link_text')->click();
$self->driver->fill_element('//*[@id="reselleridtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($self->driver->find_element_by_css('#reselleridtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$self->driver->fill_element('//*[@id="reselleridtable_filter"]/label/input', 'xpath', $resellername);
ok($self->driver->wait_for_text('//*[@id="reselleridtable"]/tbody/tr[1]/td[2]', $resellername), "Reseller found");
$self->driver->select_if_unselected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input', 'xpath');
$self->driver->fill_element('//*[@id="level"]', 'xpath', $ncosname);
$self->driver->find_element('//*[@id="mode"]/option[@value="blacklist"]')->click();
$self->driver->fill_element('//*[@id="description"]', 'xpath', "This is a simple description");
$self->driver->find_element('//*[@id="save"]')->click();
is($self->driver->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "NCOS level successfully created", "Correct Alert was shown");
}
sub delete_ncos {
my($self, $ncosname, $cancel) = @_;
return unless $ncosname;
diag('Go to NCOS interface');
$self->driver->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$self->driver->find_element("NCOS Levels", 'link_text')->click();
diag("Trying to delete NCOS");
$self->driver->fill_element('//*[@id="ncos_level_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($self->driver->find_element_by_css('#ncos_level_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$self->driver->fill_element('//*[@id="ncos_level_table_filter"]/label/input', 'xpath', $ncosname);
ok($self->driver->wait_for_text('//*[@id="ncos_level_table"]/tbody/tr[1]/td[3]', $ncosname), "NCOS found");
$self->driver->move_and_click('//*[@id="ncos_level_table"]/tbody/tr[1]/td/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="ncos_level_table_filter"]/label/input');
if($cancel){
popup_confirm_cancel($self, 'We are NOT going to terminate this NCOS Entry');
} else {
popup_confirm_ok($self, 'We are going to terminate this NCOS Entry');
is($self->driver->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "NCOS level successfully deleted", "Correct Alert was shown");
};
}
sub popup_confirm_ok {
my($self, $message) = @_;

@ -83,20 +83,12 @@ $d->find_element('//*[@id="save"]')->click();
diag('Check Error Messages');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Reseller field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Level Name field is required")]'));
$d->find_element('//*[@id="mod_close"]')->click();
diag('Fill in values');
$d->fill_element('//*[@id="reselleridtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#reselleridtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="reselleridtable_filter"]/label/input', 'xpath', $resellername);
ok($d->wait_for_text('//*[@id="reselleridtable"]/tbody/tr[1]/td[2]', $resellername), "Reseller found");
$d->select_if_unselected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input', 'xpath');
$d->fill_element('//*[@id="level"]', 'xpath', $ncosname);
$d->find_element('//*[@id="mode"]/option[@value="blacklist"]')->click();
$d->fill_element('//*[@id="description"]', 'xpath', "This is a simple description");
$d->find_element('//*[@id="save"]')->click();
diag('Create a normal NCOS');
$c->create_ncos($resellername, $ncosname);
diag('Search for our new NCOS');
is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "NCOS level successfully created", "Correct Alert was shown");
$d->fill_element('//*[@id="ncos_level_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#ncos_level_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="ncos_level_table_filter"]/label/input', 'xpath', $ncosname);
@ -253,16 +245,8 @@ diag("Check if LNP Entry was deleted");
is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "NCOS lnp entry successfully deleted", "Correct Alert was shown");
ok($d->find_element_by_css('#lnp_carriers_table tr > td.dataTables_empty', 'css'), 'LNP Entry was deleted');
diag("Go back to NCOS page");
$d->find_element("Back", 'link_text')->click();
diag("Trying to NOT delete NCOS");
$d->fill_element('//*[@id="ncos_level_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#ncos_level_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="ncos_level_table_filter"]/label/input', 'xpath', $ncosname);
ok($d->wait_for_text('//*[@id="ncos_level_table"]/tbody/tr[1]/td[3]', $ncosname), "NCOS found");
$d->move_and_click('//*[@id="ncos_level_table"]/tbody/tr[1]/td/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="ncos_level_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
$c->delete_ncos($ncosname, 1);
diag("Check if Entry is still here");
$d->fill_element('//*[@id="ncos_level_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
@ -271,11 +255,9 @@ $d->fill_element('//*[@id="ncos_level_table_filter"]/label/input', 'xpath', $nco
ok($d->wait_for_text('//*[@id="ncos_level_table"]/tbody/tr[1]/td[3]', $ncosname), "NCOS still here");
diag("Trying to delete NCOS");
$d->move_and_click('//*[@id="ncos_level_table"]/tbody/tr[1]/td/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="ncos_level_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
$c->delete_ncos($ncosname);
diag("Check if Entry was deleted");
is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "NCOS level successfully deleted", "Correct Alert was shown");
$d->fill_element('//*[@id="ncos_level_table_filter"]/label/input', 'xpath', $ncosname);
ok($d->find_element_by_css('#ncos_level_table tr > td.dataTables_empty', 'css'), 'NCOS was deleted');

Loading…
Cancel
Save