TT#56376 selenium: print more infos if test crashes

Tests will now print some infos when they crash. If a server crash occured,
it will try to get the infos from the Sorry! page + ip of the server.
If it cannot detect server issues, it prints out timestamp and server ip.

Change-Id: I7be6f405503fd38eb334134294f45dff93a17ad5
changes/76/30976/3
Nico Schedel 6 years ago
parent 085041e4ae
commit 6a633263cb

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_admin() {
my ($port) = @_;
@ -19,129 +20,152 @@ sub ctr_admin() {
my $resellername = ("reseller" . int(rand(100000)) . "test");
my $contractid = ("contract" . int(rand(100000)) . "test");
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
diag('Go to admin interface');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Administrators", 'link_text')->click();
diag('Trying to create a new administrator');
$d->find_element("Create Administrator", 'link_text')->click();
diag('Trying to save without entering anything');
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input', 'xpath');
$d->find_element('//*[@id="save"]')->click();
diag('Check if errors show up');
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(), "Login field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Please enter a password in this field")]'));
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="login"]', 'xpath', $adminname);
$d->fill_element('//*[@id="password"]', 'xpath', $adminpwd);
$d->find_element('//*[@id="save"]')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Administrator successfully created")]'), "Label 'Administrator successfully created' was shown");
diag('Search for our new admin');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
diag('Check Admin details');
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[3]', $adminname), "Name is correct");
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[2]', $resellername), "Reseller is correct");
ok($d->find_element_by_xpath('//*[@id="administrator_table"]/tbody/tr[1]/td[6][contains(text(), "0")]'), "Read-Only value is correct");
diag('Edit Admin details');
$d->move_and_click('//*[@id="administrator_table"]//tr[1]/td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="administrator_table_filter"]/label/input');
diag('Enable Attribute "Read only"');
$d->scroll_to_element($d->find_element('//form//div/label[contains(text(), "Read only")]'));
$d->select_if_unselected('//*[@id="read_only"]');
$d->find_element('//*[@id="save"]')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Administrator successfully updated")]'), "Label 'Administrator successfully updated' was shown");
diag('Check Admin details');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[3]', $adminname), "Name is correct");
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[2]', $resellername), "Reseller is correct");
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[6]', '1'), "Read-Only value is correct");
diag('New admin tries to login now');
$c->login_ok($adminname, $adminpwd);
diag('Go to admin interface');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Administrators", 'link_text')->click();
diag('Check if only your admin is shown');
ok($d->find_element_by_xpath('//*[@id="administrator_table"]/tbody/tr[1]/td[contains(text(), '. $adminname .')]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="administrator_table"]/tbody/tr[1]/td[contains(text(), '. $resellername .')]'), "Reseller is correct");
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[5]', '1'), "Read-Only value is correct");
ok($d->wait_for_text('//*[@id="administrator_table_info"]', 'Showing 1 to 1 of 1 entries'), "Only 1 entry exists");
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'administrator');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Admin table is empty');
diag("Go to Customers page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Customers", 'link_text')->click();
diag("Check if table is empty");
ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Customer Table is empty');
diag('Go to domains page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Domains", 'link_text')->click();
diag("Check if table is empty");
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Domain Table is empty');
diag('Switch over to default admin');
$c->login_ok();
diag('Go to admin interface');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Administrators", 'link_text')->click();
diag('Try to NOT delete Administrator');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[3]', $adminname), "Admin found");
$d->move_and_click('//*[@id="administrator_table"]/tbody/tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="administrator_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag('Check if admin is still here');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[3]', $adminname), "Admin is still here");
diag('Try to delete Administrator');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[3]', $adminname), "Admin found");
$d->move_and_click('//*[@id="administrator_table"]/tbody/tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="administrator_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag('Check if admin is deleted');
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Administrator successfully deleted")]'), "Label 'Administrator successfully deleted' was shown");
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Admin was deleted');
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
try {
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
diag('Go to admin interface');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Administrators", 'link_text')->click();
diag('Trying to create a new administrator');
$d->find_element("Create Administrator", 'link_text')->click();
diag('Trying to save without entering anything');
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input', 'xpath');
$d->find_element('//*[@id="save"]')->click();
diag('Check if errors show up');
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(), "Login field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Please enter a password in this field")]'));
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="login"]', 'xpath', $adminname);
$d->fill_element('//*[@id="password"]', 'xpath', $adminpwd);
$d->find_element('//*[@id="save"]')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Administrator successfully created")]'), "Label 'Administrator successfully created' was shown");
diag('Search for our new admin');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
diag('Check Admin details');
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[3]', $adminname), "Name is correct");
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[2]', $resellername), "Reseller is correct");
ok($d->find_element_by_xpath('//*[@id="administrator_table"]/tbody/tr[1]/td[6][contains(text(), "0")]'), "Read-Only value is correct");
diag('Edit Admin details');
$d->move_and_click('//*[@id="administrator_table"]//tr[1]/td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="administrator_table_filter"]/label/input');
diag('Enable Attribute "Read only"');
$d->scroll_to_element($d->find_element('//form//div/label[contains(text(), "Read only")]'));
$d->select_if_unselected('//*[@id="read_only"]');
$d->find_element('//*[@id="save"]')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Administrator successfully updated")]'), "Label 'Administrator successfully updated' was shown");
diag('Check Admin details');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[3]', $adminname), "Name is correct");
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[2]', $resellername), "Reseller is correct");
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[6]', '1'), "Read-Only value is correct");
diag('New admin tries to login now');
$c->login_ok($adminname, $adminpwd);
diag('Go to admin interface');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Administrators", 'link_text')->click();
diag('Check if only your admin is shown');
ok($d->find_element_by_xpath('//*[@id="administrator_table"]/tbody/tr[1]/td[contains(text(), '. $adminname .')]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="administrator_table"]/tbody/tr[1]/td[contains(text(), '. $resellername .')]'), "Reseller is correct");
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[5]', '1'), "Read-Only value is correct");
ok($d->wait_for_text('//*[@id="administrator_table_info"]', 'Showing 1 to 1 of 1 entries'), "Only 1 entry exists");
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'administrator');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Admin table is empty');
diag("Go to Customers page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Customers", 'link_text')->click();
diag("Check if table is empty");
ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Customer Table is empty');
diag('Go to domains page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Domains", 'link_text')->click();
diag("Check if table is empty");
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Domain Table is empty');
diag('Switch over to default admin');
$c->login_ok();
diag('Go to admin interface');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Administrators", 'link_text')->click();
diag('Try to NOT delete Administrator');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[3]', $adminname), "Admin found");
$d->move_and_click('//*[@id="administrator_table"]/tbody/tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="administrator_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag('Check if admin is still here');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[3]', $adminname), "Admin is still here");
diag('Try to delete Administrator');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
ok($d->wait_for_text('//*[@id="administrator_table"]/tbody/tr[1]/td[3]', $adminname), "Admin found");
$d->move_and_click('//*[@id="administrator_table"]/tbody/tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="administrator_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag('Check if admin is deleted');
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Administrator successfully deleted")]'), "Label 'Administrator successfully deleted' was shown");
$d->fill_element('//*[@id="administrator_table_filter"]/label/input', 'xpath', $adminname);
ok($d->find_element_by_css('#administrator_table tr > td.dataTables_empty', 'css'), 'Admin was deleted');
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_billing {
my ($port) = @_;
@ -18,206 +19,229 @@ sub ctr_billing {
my $resellername = ("reseller" . int(rand(100000)) . "test");
my $contractid = ("contract" . int(rand(100000)) . "test");
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
$c->create_billing_profile($billingname, $resellername);
diag('Trying to create a empty billing profile');
$d->find_element('Create Billing Profile', 'link_text')->click();
diag("Click 'Save'");
$d->find_element('//*[@id="save"]')->click();
diag('Check if Errors show up');
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(), "Handle field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
$d->find_element('//*[@id="mod_close"]')->click();
diag('Search for Test Profile in billing profile');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', $billingname);
diag('Check if values are correct');
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[3]', $resellername), 'Correct reseller was found');
diag("Open edit dialog for Test Profile");
$d->move_and_click('//*[@id="billing_profile_table"]/tbody/tr[1]//td//div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="billing_profile_table_filter"]//input');
diag("Edit Test Profile");
$d->fill_element('#interval_charge', 'css', '3.2');
$d->find_element('#save', 'css')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Billing profile successfully updated")]'), "Label 'Billing profile successfully updated' was shown");
diag('Open "Fees" for Test Profile');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', $billingname);
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
$d->move_and_click('//*[@id="billing_profile_table"]/tbody/tr[1]//td//div//a[contains(text(), "Fees")]', 'xpath', '//*[@id="billing_profile_table_filter"]//input');
diag("Create a billing fee");
$d->find_element('Create Fee Entry', 'link_text')->click();
diag("Press 'Save'");
$d->find_element('#save', 'css')->click();
diag('Check if Errors show up');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Zone field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Destination field is required")]'));
diag("Create a billing zone (redirect from previous form)");
$d->find_element('//div[contains(@class,"modal")]//input[@value="Create Zone"]')->click();
diag("Press 'Save'");
$d->find_element('#save', 'css')->click();
diag('Check if Errors show up');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Zone field is required")]'));
diag('Fill Zone info');
$d->fill_element('#zone', 'css', 'testingzone');
$d->fill_element('#detail', 'css', 'testingdetail');
$d->find_element('#save', 'css')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Billing Zone successfully created")]'), "Label 'Billing Zone successfully created' was shown");
diag("Back to orignial form (create billing fees)");
$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', '.+');
$d->find_element('//*[@id="direction"]/option[@value="in"]')->click();
$d->find_element('#save', 'css')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Billing Fee successfully created!")]'), "Label 'Billing Fee successfully created!' was shown");
diag("Check if billing fee values are correct");
$d->fill_element('//*[@id="billing_fee_table_filter"]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_fee_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('//*[@id="billing_fee_table_filter"]//input', 'xpath', '.+');
ok($d->wait_for_text('//*[@id="billing_fee_table"]/tbody/tr/td[2]', '.*'), 'Source pattern is correct');
ok($d->wait_for_text('//*[@id="billing_fee_table"]/tbody/tr/td[3]', '.+'), 'Destination pattern is correct');
ok($d->wait_for_text('//*[@id="billing_fee_table"]/tbody/tr/td[5]', 'in'), 'Direction pattern is correct');
ok($d->wait_for_text('//*[@id="billing_fee_table"]/tbody/tr/td[6]', 'testingdetail'), 'Billing zone is correct');
diag("Delete billing fee");
$d->move_and_click('//*[@id="billing_fee_table"]/tbody/tr[1]/td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="billing_fee_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
diag("Check if billing fee was deleted");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Billing fee successfully deleted!")]'), "Label 'Billing fee successfully deleted!' was shown");
$d->find_element('//*[@id="billing_fee_table_filter"]//input')->clear();
$d->fill_element('//*[@id="billing_fee_table_filter"]//input', 'xpath', '.+');
ok($d->find_element_by_css('#billing_fee_table tr > td.dataTables_empty'), 'Billing fee was deleted');
diag("Click Edit Zones");
$d->find_element("Edit Zones", 'link_text')->click();
ok($d->find_element('//*[@id="masthead"]//h2[contains(text(),"Billing Zones")]'));
diag("Check if billing zone values are correct");
ok($d->wait_for_text('//*[@id="billing_zone_table"]/tbody/tr/td[2]', 'testingzone'), 'Billing zone name is correct');
ok($d->wait_for_text('//*[@id="billing_zone_table"]/tbody/tr/td[3]', 'testingdetail'), 'Billing zone detail is correct');
diag("Delete testingzone");
$d->fill_element('//*[@id="billing_zone_table_filter"]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_zone_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('//*[@id="billing_zone_table_filter"]//input', 'xpath', 'testingdetail');
$d->move_and_click('//div[contains(@class,"dataTables_wrapper")]//td[contains(text(),"testingzone")]/..//a[contains(text(),"Delete")]', 'xpath', '//*[@id="billing_zone_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
diag("Check if Billing zone was deleted");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Billing zone successfully deleted")]'), "Label 'Billing zone successfully deleted' was shown");
$d->find_element('//*[@id="billing_zone_table_filter"]//input')->clear();
$d->fill_element('//*[@id="billing_zone_table_filter"]//input', 'xpath', 'testingdetail');
ok($d->find_element_by_css('#billing_zone_table tr > td.dataTables_empty'), 'Billing zone was deleted');
diag("Go to Billing page (again)");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
ok($d->find_element('//a[contains(@href,"/domain")]'));
$d->find_element("Billing", 'link_text')->click();
diag('Open "Edit Peak Times" for Test Profile');
$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');
$d->fill_element('#billing_profile_table_filter label input', 'css', $billingname);
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
$d->move_and_click('//*[@id="billing_profile_table"]/tbody/tr[1]//td//div//a[contains(text(), "Off-Peaktimes")]', 'xpath', '//*[@id="billing_profile_table_filter"]//input');
diag("Edit Wednesday");
$d->move_and_click('//table//td[contains(text(),"Wednesday")]/..//a[text()[contains(.,"Edit")]]', 'xpath', '//h3[contains(text(),"Weekdays")]');
ok($d->find_text("Edit Wednesday"), 'Edit dialog was opened');
diag("add/delete a time def to Wednesday");
$d->fill_element('#start', 'css', "04:20:00");
$d->fill_element('#end', 'css', "13:37:00");
$d->find_element('#add', 'css')->click();
$d->find_element('#mod_close', 'css')->click();
diag("check if time def has correct values");
ok($d->find_element_by_xpath('//*[@id="content"]/div/table/tbody/tr[3]/td[text()[contains(.,"04:20:00")]]'), "Time def 1 is correct");
ok($d->find_element_by_xpath('//*[@id="content"]/div/table/tbody/tr[3]/td[text()[contains(.,"13:37:00")]]'), "Time def 2 is correct");
diag("Create a Date Definition");
$d->find_element('Create Special Off-Peak Date', 'link_text')->click();
diag("Click 'Save'");
$d->find_element('//*[@id="save"]')->click();
diag('Check if Errors show up');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Start Date/Time field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "End Date/Time field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid date format, must be YYYY-MM-DD hh:mm:ss")]'));
diag('Fill in invalid values');
$d->fill_element('#start', 'css', "this should");
$d->fill_element('#end', 'css', "not work");
$d->find_element('#save', 'css')->click();
diag('Check if Errors show up');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Could not parse DateTime input. Should be one of (Y-m-d H:M:S, Y-m-d H:M, Y-m-d).")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid date format, must be YYYY-MM-DD hh:mm:ss")]'));
diag('Fill in valid values');
$d->fill_element('#start', 'css', "2008-02-28 04:20:00");
$d->fill_element('#end', 'css', "2008-02-28 13:37:00");
$d->find_element('#save', 'css')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Special offpeak entry successfully created")]'), "Label 'Special offpeak entry successfully created' was shown");
diag("Check if created date definition is correct");
$d->scroll_to_element($d->find_element('//div[contains(@class, "dataTables_filter")]//input'));
$d->fill_element('//div[contains(@class, "dataTables_filter")]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#date_definition_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//div[contains(@class, "dataTables_filter")]//input', 'xpath', '2008-02-28 04:20:00');
ok($d->wait_for_text('//*[@id="date_definition_table"]/tbody/tr/td[2]', '2008-02-28 04:20:00'), 'Start Date definition is correct');
ok($d->wait_for_text('//*[@id="date_definition_table"]/tbody/tr/td[3]', '2008-02-28 13:37:00'), 'End Date definition is correct');
diag("Delete my created date definition");
$d->move_and_click('//*[@id="date_definition_table"]/tbody//tr//td//div//a[contains(text(),"Delete")]', 'xpath', '//div[contains(@class, "dataTables_filter")]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
diag("Check if created date definition was deleted");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Special offpeak entry successfully deleted")]'), "Label 'Special offpeak entry successfully deleted' was shown");
ok($d->find_element_by_css('#date_definition_table tr > td.dataTables_empty'), 'Table is empty');
diag("Open delete dialog and press cancel");
$c->delete_billing_profile($billingname, 1);
diag("Check if Billing Profile is still here");
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', $billingname);
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
diag("Open delete dialog and press ok");
$c->delete_billing_profile($billingname);
diag("Check if Billing Profile has been removed");
$d->fill_element('#billing_profile_table_filter label input', 'css', $billingname);
ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty', 'css'), 'Billing Profile has been removed');
try {
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
$c->create_billing_profile($billingname, $resellername);
diag('Trying to create a empty billing profile');
$d->find_element('Create Billing Profile', 'link_text')->click();
diag("Click 'Save'");
$d->find_element('//*[@id="save"]')->click();
diag('Check if Errors show up');
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(), "Handle field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
$d->find_element('//*[@id="mod_close"]')->click();
diag('Search for Test Profile in billing profile');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', $billingname);
diag('Check if values are correct');
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[3]', $resellername), 'Correct reseller was found');
diag("Open edit dialog for Test Profile");
$d->move_and_click('//*[@id="billing_profile_table"]/tbody/tr[1]//td//div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="billing_profile_table_filter"]//input');
diag("Edit Test Profile");
$d->fill_element('#interval_charge', 'css', '3.2');
$d->find_element('#save', 'css')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Billing profile successfully updated")]'), "Label 'Billing profile successfully updated' was shown");
diag('Open "Fees" for Test Profile');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', $billingname);
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
$d->move_and_click('//*[@id="billing_profile_table"]/tbody/tr[1]//td//div//a[contains(text(), "Fees")]', 'xpath', '//*[@id="billing_profile_table_filter"]//input');
diag("Create a billing fee");
$d->find_element('Create Fee Entry', 'link_text')->click();
diag("Press 'Save'");
$d->find_element('#save', 'css')->click();
diag('Check if Errors show up');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Zone field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Destination field is required")]'));
diag("Create a billing zone (redirect from previous form)");
$d->find_element('//div[contains(@class,"modal")]//input[@value="Create Zone"]')->click();
diag("Press 'Save'");
$d->find_element('#save', 'css')->click();
diag('Check if Errors show up');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Zone field is required")]'));
diag('Fill Zone info');
$d->fill_element('#zone', 'css', 'testingzone');
$d->fill_element('#detail', 'css', 'testingdetail');
$d->find_element('#save', 'css')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Billing Zone successfully created")]'), "Label 'Billing Zone successfully created' was shown");
diag("Back to orignial form (create billing fees)");
$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', '.+');
$d->find_element('//*[@id="direction"]/option[@value="in"]')->click();
$d->find_element('#save', 'css')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Billing Fee successfully created!")]'), "Label 'Billing Fee successfully created!' was shown");
diag("Check if billing fee values are correct");
$d->fill_element('//*[@id="billing_fee_table_filter"]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_fee_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('//*[@id="billing_fee_table_filter"]//input', 'xpath', '.+');
ok($d->wait_for_text('//*[@id="billing_fee_table"]/tbody/tr/td[2]', '.*'), 'Source pattern is correct');
ok($d->wait_for_text('//*[@id="billing_fee_table"]/tbody/tr/td[3]', '.+'), 'Destination pattern is correct');
ok($d->wait_for_text('//*[@id="billing_fee_table"]/tbody/tr/td[5]', 'in'), 'Direction pattern is correct');
ok($d->wait_for_text('//*[@id="billing_fee_table"]/tbody/tr/td[6]', 'testingdetail'), 'Billing zone is correct');
diag("Delete billing fee");
$d->move_and_click('//*[@id="billing_fee_table"]/tbody/tr[1]/td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="billing_fee_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
diag("Check if billing fee was deleted");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Billing fee successfully deleted!")]'), "Label 'Billing fee successfully deleted!' was shown");
$d->find_element('//*[@id="billing_fee_table_filter"]//input')->clear();
$d->fill_element('//*[@id="billing_fee_table_filter"]//input', 'xpath', '.+');
ok($d->find_element_by_css('#billing_fee_table tr > td.dataTables_empty'), 'Billing fee was deleted');
diag("Click Edit Zones");
$d->find_element("Edit Zones", 'link_text')->click();
ok($d->find_element('//*[@id="masthead"]//h2[contains(text(),"Billing Zones")]'));
diag("Check if billing zone values are correct");
ok($d->wait_for_text('//*[@id="billing_zone_table"]/tbody/tr/td[2]', 'testingzone'), 'Billing zone name is correct');
ok($d->wait_for_text('//*[@id="billing_zone_table"]/tbody/tr/td[3]', 'testingdetail'), 'Billing zone detail is correct');
diag("Delete testingzone");
$d->fill_element('//*[@id="billing_zone_table_filter"]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_zone_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('//*[@id="billing_zone_table_filter"]//input', 'xpath', 'testingdetail');
$d->move_and_click('//div[contains(@class,"dataTables_wrapper")]//td[contains(text(),"testingzone")]/..//a[contains(text(),"Delete")]', 'xpath', '//*[@id="billing_zone_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
diag("Check if Billing zone was deleted");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Billing zone successfully deleted")]'), "Label 'Billing zone successfully deleted' was shown");
$d->find_element('//*[@id="billing_zone_table_filter"]//input')->clear();
$d->fill_element('//*[@id="billing_zone_table_filter"]//input', 'xpath', 'testingdetail');
ok($d->find_element_by_css('#billing_zone_table tr > td.dataTables_empty'), 'Billing zone was deleted');
diag("Go to Billing page (again)");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
ok($d->find_element('//a[contains(@href,"/domain")]'));
$d->find_element("Billing", 'link_text')->click();
diag('Open "Edit Peak Times" for Test Profile');
$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');
$d->fill_element('#billing_profile_table_filter label input', 'css', $billingname);
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
$d->move_and_click('//*[@id="billing_profile_table"]/tbody/tr[1]//td//div//a[contains(text(), "Off-Peaktimes")]', 'xpath', '//*[@id="billing_profile_table_filter"]//input');
diag("Edit Wednesday");
$d->move_and_click('//table//td[contains(text(),"Wednesday")]/..//a[text()[contains(.,"Edit")]]', 'xpath', '//h3[contains(text(),"Weekdays")]');
ok($d->find_text("Edit Wednesday"), 'Edit dialog was opened');
diag("add/delete a time def to Wednesday");
$d->fill_element('#start', 'css', "04:20:00");
$d->fill_element('#end', 'css', "13:37:00");
$d->find_element('#add', 'css')->click();
$d->find_element('#mod_close', 'css')->click();
diag("check if time def has correct values");
ok($d->find_element_by_xpath('//*[@id="content"]/div/table/tbody/tr[3]/td[text()[contains(.,"04:20:00")]]'), "Time def 1 is correct");
ok($d->find_element_by_xpath('//*[@id="content"]/div/table/tbody/tr[3]/td[text()[contains(.,"13:37:00")]]'), "Time def 2 is correct");
diag("Create a Date Definition");
$d->find_element('Create Special Off-Peak Date', 'link_text')->click();
diag("Click 'Save'");
$d->find_element('//*[@id="save"]')->click();
diag('Check if Errors show up');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Start Date/Time field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "End Date/Time field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid date format, must be YYYY-MM-DD hh:mm:ss")]'));
diag('Fill in invalid values');
$d->fill_element('#start', 'css', "this should");
$d->fill_element('#end', 'css', "not work");
$d->find_element('#save', 'css')->click();
diag('Check if Errors show up');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Could not parse DateTime input. Should be one of (Y-m-d H:M:S, Y-m-d H:M, Y-m-d).")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid date format, must be YYYY-MM-DD hh:mm:ss")]'));
diag('Fill in valid values');
$d->fill_element('#start', 'css', "2008-02-28 04:20:00");
$d->fill_element('#end', 'css', "2008-02-28 13:37:00");
$d->find_element('#save', 'css')->click();
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Special offpeak entry successfully created")]'), "Label 'Special offpeak entry successfully created' was shown");
diag("Check if created date definition is correct");
$d->scroll_to_element($d->find_element('//div[contains(@class, "dataTables_filter")]//input'));
$d->fill_element('//div[contains(@class, "dataTables_filter")]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#date_definition_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//div[contains(@class, "dataTables_filter")]//input', 'xpath', '2008-02-28 04:20:00');
ok($d->wait_for_text('//*[@id="date_definition_table"]/tbody/tr/td[2]', '2008-02-28 04:20:00'), 'Start Date definition is correct');
ok($d->wait_for_text('//*[@id="date_definition_table"]/tbody/tr/td[3]', '2008-02-28 13:37:00'), 'End Date definition is correct');
diag("Delete my created date definition");
$d->move_and_click('//*[@id="date_definition_table"]/tbody//tr//td//div//a[contains(text(),"Delete")]', 'xpath', '//div[contains(@class, "dataTables_filter")]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
diag("Check if created date definition was deleted");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Special offpeak entry successfully deleted")]'), "Label 'Special offpeak entry successfully deleted' was shown");
ok($d->find_element_by_css('#date_definition_table tr > td.dataTables_empty'), 'Table is empty');
diag("Open delete dialog and press cancel");
$c->delete_billing_profile($billingname, 1);
diag("Check if Billing Profile is still here");
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty'), 'Garbage text was not found');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', $billingname);
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
diag("Open delete dialog and press ok");
$c->delete_billing_profile($billingname);
diag("Check if Billing Profile has been removed");
$d->fill_element('#billing_profile_table_filter label input', 'css', $billingname);
ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty', 'css'), 'Billing Profile has been removed');
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_customer {
my ($port) = @_;
@ -28,217 +29,239 @@ sub ctr_customer {
print "---PBX check is ENABLED---\n";
};
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
$c->create_contact($contactmail, $resellername);
$c->create_billing_profile($billingname, $resellername);
diag("Go to Customers page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Customers", 'link_text')->click();
diag("Trying to create a empty Customer");
$d->find_element('Create Customer', 'link_text')->click();
$d->scroll_to_element($d->find_element('//table[@id="contactidtable"]/tbody/tr[1]/td//input[@type="checkbox"]'));
$d->unselect_if_selected('//table[@id="contactidtable"]/tbody/tr[1]/td//input[@type="checkbox"]');
$d->scroll_to_element($d->find_element('//table[@id="billing_profileidtable"]/tbody/tr[1]/td//input[@type="checkbox"]'));
$d->unselect_if_selected('//table[@id="billing_profileidtable"]/tbody/tr[1]/td//input[@type="checkbox"]');
$d->find_element('#save', 'css')->click();
diag("Check if error messages appear");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Contact field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid \'billing_profile_id\', not defined.")]'));
diag("Continuing creating a legit customer");
$d->find_element('//*[@id="mod_close"]')->click();
if($pbx == 1){
$c->create_customer($customerid, $contactmail, $billingname, 1);
} else {
$c->create_customer($customerid, $contactmail, $billingname);
try {
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
$c->create_contact($contactmail, $resellername);
$c->create_billing_profile($billingname, $resellername);
diag("Go to Customers page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Customers", 'link_text')->click();
diag("Trying to create a empty Customer");
$d->find_element('Create Customer', 'link_text')->click();
$d->scroll_to_element($d->find_element('//table[@id="contactidtable"]/tbody/tr[1]/td//input[@type="checkbox"]'));
$d->unselect_if_selected('//table[@id="contactidtable"]/tbody/tr[1]/td//input[@type="checkbox"]');
$d->scroll_to_element($d->find_element('//table[@id="billing_profileidtable"]/tbody/tr[1]/td//input[@type="checkbox"]'));
$d->unselect_if_selected('//table[@id="billing_profileidtable"]/tbody/tr[1]/td//input[@type="checkbox"]');
$d->find_element('#save', 'css')->click();
diag("Check if error messages appear");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Contact field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid \'billing_profile_id\', not defined.")]'));
diag("Continuing creating a legit customer");
$d->find_element('//*[@id="mod_close"]')->click();
if($pbx == 1){
$c->create_customer($customerid, $contactmail, $billingname, 1);
} else {
$c->create_customer($customerid, $contactmail, $billingname);
}
diag("Search for Customer");
$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist');
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', $customerid);
diag("Check customer details");
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $customerid . '")]'), 'Customer ID is correct');
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $resellername . '")]'), 'Reseller is correct');
ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[4]', $contactmail), 'Contact Email is correct');
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $billingname . '")]'), 'Billing Profile is correct');
diag("Edit Customer");
$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Customer_table_filter"]//input');
diag("Set status to 'locked'");
$d->scroll_to_element($d->find_element('//*[@id="status"]'));
$d->find_element('//*[@id="status"]/option[contains(text(), "locked")]')->click();
$d->find_element('#save', 'css')->click();
diag("Check if status has changed for customer");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "successfully updated")]'), "Label 'Customer successfully updated' was shown");
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "locked")]'), 'Status has changed');
diag("Open Details for our just created Customer");
$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Customer_table_filter"]//input');
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-body")]//*[contains(@class,"btn-primary") and contains(text(),"Edit Contact")]')->click();
$d->fill_element('div.modal #firstname', 'css', "Alice");
$d->fill_element('#company', 'css', 'Sipwise');
ok($d, 'Inserting name works');
$d->fill_element('#street', 'css', 'Frunze Square');
$d->fill_element('#postcode', 'css', '03141');
$d->fill_element('#city', 'css', 'Kiew');
$d->fill_element('#countryidtable_filter input', 'css', 'thisshouldnotexist');
$d->find_element('#countryidtable tr > td.dataTables_empty', 'css');
$d->fill_element('#countryidtable_filter input', 'css', 'Ukraine'); # Choosing Country
$d->select_if_unselected('//table[@id="countryidtable"]/tbody/tr[1]/td[contains(text(),"Ukraine")]/..//input[@type="checkbox"]');
$d->find_element('#save', 'css')->click(); # Save
diag("Check contact details");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Contact successfully changed")]'), "Label 'Contact successfully changed' was shown");
ok($d->wait_for_text('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Email")]/../td[2]', $contactmail), "Email is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Name")]/../td[contains(text(), "Alice")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Company")]/../td[contains(text(), "Sipwise")]'), "Company is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Address")]/../td[text()[contains(.,"03141")]]'), "Postal code is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Address")]/../td[text()[contains(.,"Kiew")]]'), "City is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Address")]/../td[text()[contains(.,"Frunze Square")]]'), "Street is correct");
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_and_click('//*[@id="collapse_fraud"]//table//tr//td[text()[contains(.,"Monthly Settings")]]/../td//a[text()[contains(.,"Edit")]]', 'xpath', '//*[@id="customer_details"]//div//a[contains(text(),"Fraud Limits")]');
$d->fill_element('#fraud_interval_limit', 'css', "100");
$d->fill_element('#fraud_interval_notify', 'css', 'mymail@example.org');
$d->find_element('#save', 'css')->click();
diag("Check Fraud Limit details");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Fraud settings successfully changed!")]'), "Label 'Fraud settings successfully changed!' was shown");
ok($d->find_element_by_xpath('//*[@id="collapse_fraud"]//table//tr//td[contains(text(), "Monthly Settings")]/../td[contains(text(), "100")]'), "Limit is correct");
ok($d->wait_for_text('//*[@id="collapse_fraud"]//table//tr//td[contains(text(), "Monthly Settings")]/../td[4]', 'mymail@example.org'), "Mail is correct");
diag("Create a new Phonebook entry");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]'));
diag("Trying to create a empty Phonebook entry");
$d->find_element("Create Phonebook Entry", 'link_text')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check if error messages appear");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Number field is required")]'));
diag("Enter Information");
$d->fill_element('//*[@id="name"]', 'xpath', 'Tester');
$d->fill_element('//*[@id="number"]', 'xpath', '0123456789');
$d->find_element('//*[@id="save"]')->click();
diag("Search for Phonebook Entry");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]'));
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#phonebook_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'Tester');
diag("Check Phonebook entry details");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Phonebook entry successfully created")]'), "Label 'Phonebook entry successfully created' was shown");
ok($d->find_element_by_xpath('//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "Tester")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "0123456789")]'), "Number is correct");
diag("Edit Phonebook entry");
$d->move_and_click('//*[@id="phonebook_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="customer_details"]//div//a[contains(text(), "Phonebook")]');
diag("Change Information");
$d->fill_element('//*[@id="name"]', 'xpath', 'TesterTester');
$d->fill_element('//*[@id="number"]', 'xpath', '987654321');
$d->find_element('//*[@id="save"]')->click();
diag("Check if information has changed");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]'));
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#phonebook_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'TesterTester');
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Phonebook entry successfully updated")]'), "Label 'Phonebook entry successfully updated' was shown");
ok($d->find_element_by_xpath('//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "TesterTester")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "987654321")]'), "Number is correct");
diag("Create a new Location");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Locations")]')->click();
$d->find_element("Create Location", 'link_text')->click();
diag("Trying to create a empty Location");
$d->find_element('//*[@id="save"]')->click();
diag("Check if Error messages appear");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Location Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Description field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Blocks field is required")]'));
diag('Enter information');
$d->fill_element('//*[@id="name"]', 'xpath', 'Test Location');
$d->fill_element('//*[@id="description"]', 'xpath', 'This is a Test Location');
$d->fill_element('//*[@id="name"]', 'xpath', 'Test Location');
$d->fill_element('//*[@id="blocks.0.row.ip"]', 'xpath', '127.0.0.1');
$d->fill_element('//*[@id="blocks.0.row.mask"]', 'xpath', '16');
$d->find_element('//*[@id="save"]')->click();
diag("Search for Location");
$d->find_element('//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]'));
$d->fill_element('//*[@id="locations_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#locations_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="locations_table_filter"]/label/input', 'xpath', 'Test Location');
diag("Check location details");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Location successfully created")]'), "Label 'Location successfully created' was shown");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "Test Location")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "This is a Test Location")]'), "Description is correct");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "127.0.0.1/16")]'), "Network block is correct");
diag("Edit Location");
$d->move_and_click('//*[@id="locations_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="customer_details"]//div//a[contains(text(), "Locations")]');
$d->fill_element('//*[@id="description"]', 'xpath', 'This is a very Test Location');
$d->fill_element('//*[@id="name"]', 'xpath', 'TestTest Location');
$d->fill_element('//*[@id="blocks.0.row.ip"]', 'xpath', '10.0.0.138');
$d->fill_element('//*[@id="blocks.0.row.mask"]', 'xpath', '16');
$d->find_element('//*[@id="save"]')->click();
diag("Search for Location");
$d->find_element('//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]'));
$d->fill_element('//*[@id="locations_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#locations_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="locations_table_filter"]/label/input', 'xpath', 'TestTest Location');
diag("Check location details");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Location successfully updated")]'), "Label 'Location successfully updated' was shown");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "TestTest Location")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "This is a very Test Location")]'), "Description is correct");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "10.0.0.138/16")]'), "Network block is correct");
diag("Open delete dialog and press cancel");
$c->delete_customer($customerid, 1);
$d->fill_element('//*[@id="Customer_table_filter"]/label/input', 'xpath', $customerid);
ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr/td[2]', $customerid), 'Customer is still here');
diag('Open delete dialog and press delete');
$c->delete_customer($customerid, 0);
$d->fill_element('//*[@id="Customer_table_filter"]/label/input', 'xpath', $customerid);
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Customer successfully terminated")]'), "Label 'Customer successfully terminated' was shown");
ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Customer was deleted');
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
$c->delete_contact($contactmail);
$c->delete_billing_profile($billingname);
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
diag("Search for Customer");
$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist');
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', $customerid);
diag("Check customer details");
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $customerid . '")]'), 'Customer ID is correct');
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $resellername . '")]'), 'Reseller is correct');
ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[4]', $contactmail), 'Contact Email is correct');
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $billingname . '")]'), 'Billing Profile is correct');
diag("Edit Customer");
$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Customer_table_filter"]//input');
diag("Set status to 'locked'");
$d->scroll_to_element($d->find_element('//*[@id="status"]'));
$d->find_element('//*[@id="status"]/option[contains(text(), "locked")]')->click();
$d->find_element('#save', 'css')->click();
diag("Check if status has changed for customer");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "successfully updated")]'), "Label 'Customer successfully updated' was shown");
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "locked")]'), 'Status has changed');
diag("Open Details for our just created Customer");
$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Customer_table_filter"]//input');
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-body")]//*[contains(@class,"btn-primary") and contains(text(),"Edit Contact")]')->click();
$d->fill_element('div.modal #firstname', 'css', "Alice");
$d->fill_element('#company', 'css', 'Sipwise');
ok($d, 'Inserting name works');
$d->fill_element('#street', 'css', 'Frunze Square');
$d->fill_element('#postcode', 'css', '03141');
$d->fill_element('#city', 'css', 'Kiew');
$d->fill_element('#countryidtable_filter input', 'css', 'thisshouldnotexist');
$d->find_element('#countryidtable tr > td.dataTables_empty', 'css');
$d->fill_element('#countryidtable_filter input', 'css', 'Ukraine'); # Choosing Country
$d->select_if_unselected('//table[@id="countryidtable"]/tbody/tr[1]/td[contains(text(),"Ukraine")]/..//input[@type="checkbox"]');
$d->find_element('#save', 'css')->click(); # Save
diag("Check contact details");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Contact successfully changed")]'), "Label 'Contact successfully changed' was shown");
ok($d->wait_for_text('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Email")]/../td[2]', $contactmail), "Email is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Name")]/../td[contains(text(), "Alice")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Company")]/../td[contains(text(), "Sipwise")]'), "Company is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Address")]/../td[text()[contains(.,"03141")]]'), "Postal code is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Address")]/../td[text()[contains(.,"Kiew")]]'), "City is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contains(text(), "Address")]/../td[text()[contains(.,"Frunze Square")]]'), "Street is correct");
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_and_click('//*[@id="collapse_fraud"]//table//tr//td[text()[contains(.,"Monthly Settings")]]/../td//a[text()[contains(.,"Edit")]]', 'xpath', '//*[@id="customer_details"]//div//a[contains(text(),"Fraud Limits")]');
$d->fill_element('#fraud_interval_limit', 'css', "100");
$d->fill_element('#fraud_interval_notify', 'css', 'mymail@example.org');
$d->find_element('#save', 'css')->click();
diag("Check Fraud Limit details");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Fraud settings successfully changed!")]'), "Label 'Fraud settings successfully changed!' was shown");
ok($d->find_element_by_xpath('//*[@id="collapse_fraud"]//table//tr//td[contains(text(), "Monthly Settings")]/../td[contains(text(), "100")]'), "Limit is correct");
ok($d->wait_for_text('//*[@id="collapse_fraud"]//table//tr//td[contains(text(), "Monthly Settings")]/../td[4]', 'mymail@example.org'), "Mail is correct");
diag("Create a new Phonebook entry");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]'));
diag("Trying to create a empty Phonebook entry");
$d->find_element("Create Phonebook Entry", 'link_text')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check if error messages appear");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Number field is required")]'));
diag("Enter Information");
$d->fill_element('//*[@id="name"]', 'xpath', 'Tester');
$d->fill_element('//*[@id="number"]', 'xpath', '0123456789');
$d->find_element('//*[@id="save"]')->click();
diag("Search for Phonebook Entry");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]'));
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#phonebook_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'Tester');
diag("Check Phonebook entry details");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Phonebook entry successfully created")]'), "Label 'Phonebook entry successfully created' was shown");
ok($d->find_element_by_xpath('//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "Tester")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "0123456789")]'), "Number is correct");
diag("Edit Phonebook entry");
$d->move_and_click('//*[@id="phonebook_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="customer_details"]//div//a[contains(text(), "Phonebook")]');
diag("Change Information");
$d->fill_element('//*[@id="name"]', 'xpath', 'TesterTester');
$d->fill_element('//*[@id="number"]', 'xpath', '987654321');
$d->find_element('//*[@id="save"]')->click();
diag("Check if information has changed");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]'));
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#phonebook_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'TesterTester');
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Phonebook entry successfully updated")]'), "Label 'Phonebook entry successfully updated' was shown");
ok($d->find_element_by_xpath('//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "TesterTester")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "987654321")]'), "Number is correct");
diag("Create a new Location");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Locations")]')->click();
$d->find_element("Create Location", 'link_text')->click();
diag("Trying to create a empty Location");
$d->find_element('//*[@id="save"]')->click();
diag("Check if Error messages appear");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Location Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Description field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Blocks field is required")]'));
diag('Enter information');
$d->fill_element('//*[@id="name"]', 'xpath', 'Test Location');
$d->fill_element('//*[@id="description"]', 'xpath', 'This is a Test Location');
$d->fill_element('//*[@id="name"]', 'xpath', 'Test Location');
$d->fill_element('//*[@id="blocks.0.row.ip"]', 'xpath', '127.0.0.1');
$d->fill_element('//*[@id="blocks.0.row.mask"]', 'xpath', '16');
$d->find_element('//*[@id="save"]')->click();
diag("Search for Location");
$d->find_element('//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]'));
$d->fill_element('//*[@id="locations_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#locations_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="locations_table_filter"]/label/input', 'xpath', 'Test Location');
diag("Check location details");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Location successfully created")]'), "Label 'Location successfully created' was shown");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "Test Location")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "This is a Test Location")]'), "Description is correct");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "127.0.0.1/16")]'), "Network block is correct");
diag("Edit Location");
$d->move_and_click('//*[@id="locations_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="customer_details"]//div//a[contains(text(), "Locations")]');
$d->fill_element('//*[@id="description"]', 'xpath', 'This is a very Test Location');
$d->fill_element('//*[@id="name"]', 'xpath', 'TestTest Location');
$d->fill_element('//*[@id="blocks.0.row.ip"]', 'xpath', '10.0.0.138');
$d->fill_element('//*[@id="blocks.0.row.mask"]', 'xpath', '16');
$d->find_element('//*[@id="save"]')->click();
diag("Search for Location");
$d->find_element('//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]'));
$d->fill_element('//*[@id="locations_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#locations_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="locations_table_filter"]/label/input', 'xpath', 'TestTest Location');
diag("Check location details");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Location successfully updated")]'), "Label 'Location successfully updated' was shown");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "TestTest Location")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "This is a very Test Location")]'), "Description is correct");
ok($d->find_element_by_xpath('//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "10.0.0.138/16")]'), "Network block is correct");
diag("Open delete dialog and press cancel");
$c->delete_customer($customerid, 1);
$d->fill_element('//*[@id="Customer_table_filter"]/label/input', 'xpath', $customerid);
ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr/td[2]', $customerid), 'Customer is still here');
diag('Open delete dialog and press delete');
$c->delete_customer($customerid, 0);
$d->fill_element('//*[@id="Customer_table_filter"]/label/input', 'xpath', $customerid);
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Customer successfully terminated")]'), "Label 'Customer successfully terminated' was shown");
ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Customer was deleted');
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
$c->delete_contact($contactmail);
$c->delete_billing_profile($billingname);
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag like)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_domain {
my ($port) = @_;
@ -16,155 +17,178 @@ sub ctr_domain {
my $domainstring = ("domain" . int(rand(100000)) . ".example.org");
$c->login_ok();
try {
$c->login_ok();
diag('Go to domains page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Domains", 'link_text')->click();
diag('Go to domains page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Domains", 'link_text')->click();
diag('Try to add a empty domain');
$d->find_element('Create Domain', 'link_text')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Try to add a empty domain');
$d->find_element('Create Domain', 'link_text')->click();
$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(), "SIP Domain field is required")]'));
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(), "SIP Domain field is required")]'));
diag("Continuing creating a legit domain");
$d->find_element('//*[@id="mod_close"]')->click();
diag("Continuing creating a legit domain");
$d->find_element('//*[@id="mod_close"]')->click();
$c->create_domain($domainstring);
$c->create_domain($domainstring);
diag("Check if entry exists and if the search works");
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
diag("Check if entry exists and if the search works");
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
diag("Check domain details");
ok($d->find_element_by_xpath('//*[@id="Domain_table"]/tbody/tr[1]/td[contains(text(), "default")]'), "Reseller is correct");
ok($d->wait_for_text('//*[@id="Domain_table"]/tbody/tr[1]/td[contains(text(), "domain")]', $domainstring), "Domain name is correct");
diag("Check domain details");
ok($d->find_element_by_xpath('//*[@id="Domain_table"]/tbody/tr[1]/td[contains(text(), "default")]'), "Reseller is correct");
ok($d->wait_for_text('//*[@id="Domain_table"]/tbody/tr[1]/td[contains(text(), "domain")]', $domainstring), "Domain name is correct");
diag("Open Preferences of first Domain");
$d->move_and_click('//*[@id="Domain_table"]//tr[1]//td//a[contains(text(), "Preferences")]', 'xpath', '//*[@id="Domain_table_filter"]/label/input');
diag("Open Preferences of first Domain");
$d->move_and_click('//*[@id="Domain_table"]//tr[1]//td//a[contains(text(), "Preferences")]', 'xpath', '//*[@id="Domain_table_filter"]/label/input');
diag('Open the tab "Access Restrictions"');
$d->find_element("Access Restrictions", 'link_text')->click();
diag('Open the tab "Access Restrictions"');
$d->find_element("Access Restrictions", 'link_text')->click();
diag("Click edit for the preference concurrent_max");
$d->move_and_click('//table//tr/td[contains(text(), "concurrent_max")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr/td[contains(text(), "reject_emergency")]');
diag("Click edit for the preference concurrent_max");
$d->move_and_click('//table//tr/td[contains(text(), "concurrent_max")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr/td[contains(text(), "reject_emergency")]');
diag("Try to change this to a value which is not a number");
$d->fill_element('#concurrent_max', 'css', 'thisisnonumber');
$d->find_element("#save", 'css')->click();
diag("Try to change this to a value which is not a number");
$d->fill_element('#concurrent_max', 'css', 'thisisnonumber');
$d->find_element("#save", 'css')->click();
diag("Check error message");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Value must be an integer")]'));
diag("Check error message");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Value must be an integer")]'));
diag('Type 789 and click Save');
ok($d->find_text('Value must be an integer'), 'Wrong value detected');
$d->fill_element('#concurrent_max', 'css', '789');
$d->find_element('#save', 'css')->click();
diag('Type 789 and click Save');
ok($d->find_text('Value must be an integer'), 'Wrong value detected');
$d->fill_element('#concurrent_max', 'css', '789');
$d->find_element('#save', 'css')->click();
diag('Check if value has been applied');
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Preference concurrent_max successfully updated")]'), "Label 'Preference concurrent_max successfully updated' was shown");
ok($d->find_element_by_xpath('//table/tbody/tr/td[contains(text(), "concurrent_max")]/../td[contains(text(), "789")]'), "Value has been applied");
diag('Check if value has been applied');
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Preference concurrent_max successfully updated")]'), "Label 'Preference concurrent_max successfully updated' was shown");
ok($d->find_element_by_xpath('//table/tbody/tr/td[contains(text(), "concurrent_max")]/../td[contains(text(), "789")]'), "Value has been applied");
diag("Click edit for the preference allowed_ips");
$d->move_and_click('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td/div/a[contains(text(), "Edit")]', 'xpath', '//table/tbody/tr/td[contains(text(), "man_allowed_ips")]/../td/div/a[contains(text(), "Edit")]');
diag("Click edit for the preference allowed_ips");
$d->move_and_click('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td/div/a[contains(text(), "Edit")]', 'xpath', '//table/tbody/tr/td[contains(text(), "man_allowed_ips")]/../td/div/a[contains(text(), "Edit")]');
diag("Enter an IP address");
diag("Enter an IP address");
=pod
$d->find_element('//*[@id="add"]')->click();
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//div//span[contains(text(), "Invalid IPv4 or IPv6 address")]'), "Invalid IP address detected");
$d->find_element('//*[@id="add"]')->click();
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//div//span[contains(text(), "Invalid IPv4 or IPv6 address")]'), "Invalid IP address detected");
=cut
$d->fill_element('//*[@id="allowed_ips"]', 'xpath', '127.0.0.0.0');
$d->find_element('//*[@id="add"]')->click();
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//div//span[contains(text(), "Invalid IPv4 or IPv6 address")]'), "Invalid IP address detected");
$d->fill_element('//*[@id="allowed_ips"]', 'xpath', 'thisisnonumber');
$d->find_element('//*[@id="add"]')->click();
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//div//span[contains(text(), "Invalid IPv4 or IPv6 address")]'), "Invalid IP address detected");
$d->fill_element('//*[@id="allowed_ips"]', 'xpath', '127.0.0.1');
$d->find_element('//*[@id="add"]')->click();
$d->find_element('//*[@id="mod_close"]')->click();
diag("Check if IP address has been added");
ok($d->find_element_by_xpath('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td[contains(text(), "127.0.0.1")]'), "IP address has beeen found");
diag("Add another IP address");
$d->move_and_click('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td/div/a[contains(text(), "Edit")]', 'xpath', '//table/tbody/tr/td[contains(text(), "man_allowed_ips")]/../td/div/a[contains(text(), "Edit")]');
$d->fill_element('//*[@id="allowed_ips"]', 'xpath', '10.0.0.138');
$d->find_element('//*[@id="add"]')->click();
$d->find_element('//*[@id="mod_close"]')->click();
diag("Check if IP address has been added");
ok($d->find_element_by_xpath('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td[contains(text(), "10.0.0.138")]'), "IP address has beeen found");
diag("Delete the first IP address");
$d->move_and_click('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td/div/a[contains(text(), "Edit")]', 'xpath', '//table/tbody/tr/td[contains(text(), "man_allowed_ips")]/../td/div/a[contains(text(), "Edit")]');
$d->find_element('//*[@id="mod_edit"]/div[2]/div[2]/a')->click();
$d->find_element('//*[@id="mod_close"]')->click();
diag("Check if IP addresses have been changed");
ok($d->find_element_by_xpath('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td[contains(text(), "10.0.0.138")]'), "IP address has beeen found");
diag("Enable transcoding to Opus Mono and Stereo");
$d->scroll_to_element($d->find_element('Media Codec Transcoding Options', 'link_text'));
$d->find_element('Media Codec Transcoding Options', 'link_text')->click();
diag("Enable Opus Mono");
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "transcode_opus_mono")]'));
$d->move_and_click('//table//tr/td[contains(text(), "transcode_opus_mono")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr/td[contains(text(), "transcode_opus_stereo")]');
$d->select_if_unselected('//*[@id="transcode_opus_mono"]');
$d->find_element('//*[@id="save"]')->click();
diag("Check if Opus Mono was enabled");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Preference transcode_opus_mono successfully updated")]'), "Label 'Preference transcode_opus_mono successfully updated' was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "transcode_opus_mono")]/../td//input[@checked="checked"]'), "Opus mono was enabled");
diag("Change Opus Mono Bitrate");
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "transcode_opus_mono")]'));
$d->move_and_click('//table//tr/td[contains(text(), "opus_mono_bitrate")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr/td[contains(text(), "opus_stereo_bitrate")]');
diag("Change to 32 kbit/s");
$d->find_element('//*[@id="opus_mono_bitrate"]/option[contains(text(), "32")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check if Bitrate was applied");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Preference opus_mono_bitrate successfully updated")]'), "Label 'Preference opus_mono_bitrate successfully updated' was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "opus_mono_bitrate")]/../td/select/option[text()[contains(., "32")]][@selected="selected"]'), "Correct bitrate was selected");
diag("Enable Opus Stereo");
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "transcode_opus_stereo")]'));
$d->move_and_click('//table//tr/td[contains(text(), "transcode_opus_stereo")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr/td[contains(text(), "transcode_opus_mono")]');
$d->select_if_unselected('//*[@id="transcode_opus_stereo"]');
$d->find_element('//*[@id="save"]')->click();
diag("Check if Opus Stereo was enabled");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Preference transcode_opus_stereo successfully updated")]'), "Label 'Preference transcode_opus_stereo successfully updated' was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "transcode_opus_stereo")]/../td//input[@checked="checked"]'), "Opus stereo was enabled");
diag("Change Opus Stereo Bitrate");
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "transcode_opus_stereo")]'));
$d->move_and_click('//table//tr/td[contains(text(), "opus_stereo_bitrate")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr/td[contains(text(), "opus_mono_bitrate")]');
diag("Change to 32 kbit/s");
$d->find_element('//*[@id="opus_stereo_bitrate"]/option[contains(text(), "32")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check if Bitrate was applied");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Preference opus_stereo_bitrate successfully updated")]'), "Label 'Preference opus_stereo_bitrate successfully updated' was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "opus_stereo_bitrate")]/../td/select/option[text()[contains(., "32")]][@selected="selected"]'), "Correct bitrate was selected");
diag("Open delete dialog and press cancel");
$c->delete_domain($domainstring, 1);
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
ok($d->wait_for_text('//*[@id="Domain_table"]/tbody/tr[1]/td[3]', $domainstring), 'Domain is still here');
diag('Open delete dialog and press delete');
$c->delete_domain($domainstring, 0);
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Domain successfully deleted!")]'), "Label 'Domain successfully deleted!' was shown");
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Domain was deleted');
$d->fill_element('//*[@id="allowed_ips"]', 'xpath', '127.0.0.0.0');
$d->find_element('//*[@id="add"]')->click();
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//div//span[contains(text(), "Invalid IPv4 or IPv6 address")]'), "Invalid IP address detected");
$d->fill_element('//*[@id="allowed_ips"]', 'xpath', 'thisisnonumber');
$d->find_element('//*[@id="add"]')->click();
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//div//span[contains(text(), "Invalid IPv4 or IPv6 address")]'), "Invalid IP address detected");
$d->fill_element('//*[@id="allowed_ips"]', 'xpath', '127.0.0.1');
$d->find_element('//*[@id="add"]')->click();
$d->find_element('//*[@id="mod_close"]')->click();
diag("Check if IP address has been added");
ok($d->find_element_by_xpath('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td[contains(text(), "127.0.0.1")]'), "IP address has beeen found");
diag("Add another IP address");
$d->move_and_click('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td/div/a[contains(text(), "Edit")]', 'xpath', '//table/tbody/tr/td[contains(text(), "man_allowed_ips")]/../td/div/a[contains(text(), "Edit")]');
$d->fill_element('//*[@id="allowed_ips"]', 'xpath', '10.0.0.138');
$d->find_element('//*[@id="add"]')->click();
$d->find_element('//*[@id="mod_close"]')->click();
diag("Check if IP address has been added");
ok($d->find_element_by_xpath('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td[contains(text(), "10.0.0.138")]'), "IP address has beeen found");
diag("Delete the first IP address");
$d->move_and_click('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td/div/a[contains(text(), "Edit")]', 'xpath', '//table/tbody/tr/td[contains(text(), "man_allowed_ips")]/../td/div/a[contains(text(), "Edit")]');
$d->find_element('//*[@id="mod_edit"]/div[2]/div[2]/a')->click();
$d->find_element('//*[@id="mod_close"]')->click();
diag("Check if IP addresses have been changed");
ok($d->find_element_by_xpath('//table/tbody/tr/td[contains(text(), "allowed_ips")]/../td[contains(text(), "10.0.0.138")]'), "IP address has beeen found");
diag("Enable transcoding to Opus Mono and Stereo");
$d->scroll_to_element($d->find_element('Media Codec Transcoding Options', 'link_text'));
$d->find_element('Media Codec Transcoding Options', 'link_text')->click();
diag("Enable Opus Mono");
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "transcode_opus_mono")]'));
$d->move_and_click('//table//tr/td[contains(text(), "transcode_opus_mono")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr/td[contains(text(), "transcode_opus_stereo")]');
$d->select_if_unselected('//*[@id="transcode_opus_mono"]');
$d->find_element('//*[@id="save"]')->click();
diag("Check if Opus Mono was enabled");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Preference transcode_opus_mono successfully updated")]'), "Label 'Preference transcode_opus_mono successfully updated' was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "transcode_opus_mono")]/../td//input[@checked="checked"]'), "Opus mono was enabled");
diag("Change Opus Mono Bitrate");
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "transcode_opus_mono")]'));
$d->move_and_click('//table//tr/td[contains(text(), "opus_mono_bitrate")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr/td[contains(text(), "opus_stereo_bitrate")]');
diag("Change to 32 kbit/s");
$d->find_element('//*[@id="opus_mono_bitrate"]/option[contains(text(), "32")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check if Bitrate was applied");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Preference opus_mono_bitrate successfully updated")]'), "Label 'Preference opus_mono_bitrate successfully updated' was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "opus_mono_bitrate")]/../td/select/option[text()[contains(., "32")]][@selected="selected"]'), "Correct bitrate was selected");
diag("Enable Opus Stereo");
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "transcode_opus_stereo")]'));
$d->move_and_click('//table//tr/td[contains(text(), "transcode_opus_stereo")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr/td[contains(text(), "transcode_opus_mono")]');
$d->select_if_unselected('//*[@id="transcode_opus_stereo"]');
$d->find_element('//*[@id="save"]')->click();
diag("Check if Opus Stereo was enabled");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Preference transcode_opus_stereo successfully updated")]'), "Label 'Preference transcode_opus_stereo successfully updated' was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "transcode_opus_stereo")]/../td//input[@checked="checked"]'), "Opus stereo was enabled");
diag("Change Opus Stereo Bitrate");
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "transcode_opus_stereo")]'));
$d->move_and_click('//table//tr/td[contains(text(), "opus_stereo_bitrate")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr/td[contains(text(), "opus_mono_bitrate")]');
diag("Change to 32 kbit/s");
$d->find_element('//*[@id="opus_stereo_bitrate"]/option[contains(text(), "32")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check if Bitrate was applied");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Preference opus_stereo_bitrate successfully updated")]'), "Label 'Preference opus_stereo_bitrate successfully updated' was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "opus_stereo_bitrate")]/../td/select/option[text()[contains(., "32")]][@selected="selected"]'), "Correct bitrate was selected");
diag("Open delete dialog and press cancel");
$c->delete_domain($domainstring, 1);
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
ok($d->wait_for_text('//*[@id="Domain_table"]/tbody/tr[1]/td[3]', $domainstring), 'Domain is still here');
diag('Open delete dialog and press delete');
$c->delete_domain($domainstring, 0);
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Domain successfully deleted!")]'), "Label 'Domain successfully deleted!' was shown");
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Domain was deleted');
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_emergency {
my ($port) = @_;
@ -19,198 +20,221 @@ sub ctr_emergency {
my $containername = ("emergency" . int(rand(100000)) . "container");
my $domainstring = ("domain" . int(rand(100000)) . ".example.org");
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
diag("Go to Emergency Mappings page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Emergency Mappings", 'link_text')->click();
diag("Trying to create a empty emergency container");
$d->find_element("Create Emergency Container", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]//tr[1]//td//input');
$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(), "Name field is required")]'));
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="name"]', 'xpath', $containername);
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Emergency Container");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
diag("Check Emergency Container details");
ok($d->find_element_by_xpath('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Container name is correct');
diag("Edit Container name");
$containername = ("emergency" . int(rand(100000)) . "container");
$d->move_and_click('//*[@id="emergency_containers_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="emergency_containers_table_filter"]//input');
$d->fill_element('//*[@id="name"]', 'xpath', $containername);
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Emergency Container");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
diag("Check Emergency Container details");
ok($d->find_element_by_xpath('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Container name is correct');
diag("Trying to create a empty Emergency Mapping");
$d->find_element("Create Emergency Mapping", 'link_text')->click();
$d->unselect_if_selected('//*[@id="emergency_containeridtable"]//tr[1]//td//input');
$d->find_element('//*[@id="save"]')->click();
diag("Check error messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Emergency Mapping Container field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Code field is required")]'));
diag("Fill in Values");
$d->fill_element('//*[@id="emergency_containeridtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containeridtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containeridtable_filter"]/label/input', 'xpath', $containername);
ok($d->wait_for_text('//*[@id="emergency_containeridtable"]/tbody/tr[1]/td[3]', $containername), "Emergency Container found");
$d->select_if_unselected('//*[@id="emergency_containeridtable"]/tbody/tr[1]/td[4]/input', 'xpath');
$d->fill_element('//*[@id="code"]', 'xpath', "133");
$d->fill_element('//*[@id="prefix"]', 'xpath', "E1_133_");
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Emergency Mapping");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
diag("Check Emergency Mapping details");
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Container name is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), "133")]'), 'Emergency Number is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), "E1_133_")]'), 'Emergency Prefix is correct');
diag("Edit Emergency Mapping Details");
$d->move_and_click('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[6]/div/a[2]', 'xpath', '//*[@id="emergency_mappings_table_filter"]//input');
$d->fill_element('//*[@id="code"]', 'xpath', "144");
$d->fill_element('//*[@id="prefix"]', 'xpath', "E2_144_");
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Emergency Mapping");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
diag("Check Emergency Mapping details");
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Container name is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), "144")]'), 'Emergency Number is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), "E2_144_")]'), 'Emergency Prefix is correct');
diag("Creating Domain to add Emergency Container");
$c->create_domain($domainstring, $resellername);
diag("Searching Domain");
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
ok($d->wait_for_text('//*[@id="Domain_table"]/tbody/tr[1]/td[contains(text(), "domain")]', $domainstring), "Domain was found");
$d->move_and_click('//*[@id="Domain_table"]//tr[1]//td//a[contains(text(), "Preferences")]', 'xpath', '//*[@id="Domain_table_filter"]/label/input');
diag("Open 'Number Manipulations'");
$d->find_element("Number Manipulations", 'link_text')->click();
$d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[contains(text(),"Number Manipulations")]'));
diag("Edit setting 'emergency_mapping_container'");
$d->scroll_to_element($d->find_element('//table//tr//td[contains(text(), "emergency_mapping_container")]'));
$d->move_and_click('//table//tr//td[contains(text(), "emergency_mapping_container")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "NAT and Media Flow Control")]');
$d->find_element('//*[@id="emergency_mapping_container"]/option[contains(text(), "' . $containername . '")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check if 'emergency_mapping_container' was applied");
ok($d->find_element_by_xpath('//table//tr//td[contains(text(), "emergency_mapping_container")]/../td/select/option[contains(text(), "' . $containername . '")][@selected="selected"]'), 'NCOS Level was applied');
diag("Open 'Internals'");
$d->find_element("Internals", 'link_text')->click();
$d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[contains(text(),"Internals")]'));
diag("Edit setting 'emergency_mode_enabled'");
$d->scroll_to_element($d->find_element('//table//tr//td[contains(text(), "emergency_mode_enabled")]'));
$d->move_and_click('//table//tr//td[contains(text(), "emergency_mode_enabled")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr//td[contains(text(), "call_deflection")]');
$d->select_if_unselected('//*[@id="emergency_mode_enabled"]');
$d->find_element('//*[@id="save"]')->click();
diag("Check if Setting was enabled");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "emergency_mode_enabled")]/../td//input[@checked="checked"]'), "Setting was enabled");
diag("Go to Emergency Mappings page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Emergency Mappings", 'link_text')->click();
diag("Trying to NOT delete Emergency Mapping");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
ok($d->wait_for_text('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[2]', $containername), 'Emergency mapping was found');
$d->move_and_click('//*[@id="emergency_mappings_table"]/tbody/tr/td[6]/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="emergency_mappings_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag("Check if Emergency Mapping is still here");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Mapping is still here');
diag("Trying to delete Emergency Mapping");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
ok($d->wait_for_text('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[2]', $containername), 'Emergency mapping was found');
$d->move_and_click('//*[@id="emergency_mappings_table"]/tbody/tr/td[6]/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="emergency_mappings_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if Emergency Mapping was deleted");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Emergency Mapping was deleted');
diag("Trying to NOT delete Emergency Container");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
ok($d->wait_for_text('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[3]', $containername), 'Emergency mapping was found');
$d->move_and_click('//*[@id="emergency_containers_table"]/tbody/tr/td[4]/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="emergency_containers_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag("Check if Emergency Container is still here");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
ok($d->find_element_by_xpath('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Container is still here');
diag("Trying to delete Emergency Container");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
ok($d->wait_for_text('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[3]', $containername), 'Emergency mapping was found');
$d->move_and_click('//*[@id="emergency_containers_table"]/tbody/tr/td[4]/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="emergency_containers_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if Emergency Container was deleted");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Emergency Mapping was deleted');
$c->delete_domain($domainstring);
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
try {
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
diag("Go to Emergency Mappings page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Emergency Mappings", 'link_text')->click();
diag("Trying to create a empty emergency container");
$d->find_element("Create Emergency Container", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]//tr[1]//td//input');
$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(), "Name field is required")]'));
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="name"]', 'xpath', $containername);
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Emergency Container");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
diag("Check Emergency Container details");
ok($d->find_element_by_xpath('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Container name is correct');
diag("Edit Container name");
$containername = ("emergency" . int(rand(100000)) . "container");
$d->move_and_click('//*[@id="emergency_containers_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="emergency_containers_table_filter"]//input');
$d->fill_element('//*[@id="name"]', 'xpath', $containername);
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Emergency Container");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
diag("Check Emergency Container details");
ok($d->find_element_by_xpath('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Container name is correct');
diag("Trying to create a empty Emergency Mapping");
$d->find_element("Create Emergency Mapping", 'link_text')->click();
$d->unselect_if_selected('//*[@id="emergency_containeridtable"]//tr[1]//td//input');
$d->find_element('//*[@id="save"]')->click();
diag("Check error messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Emergency Mapping Container field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Code field is required")]'));
diag("Fill in Values");
$d->fill_element('//*[@id="emergency_containeridtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containeridtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containeridtable_filter"]/label/input', 'xpath', $containername);
ok($d->wait_for_text('//*[@id="emergency_containeridtable"]/tbody/tr[1]/td[3]', $containername), "Emergency Container found");
$d->select_if_unselected('//*[@id="emergency_containeridtable"]/tbody/tr[1]/td[4]/input', 'xpath');
$d->fill_element('//*[@id="code"]', 'xpath', "133");
$d->fill_element('//*[@id="prefix"]', 'xpath', "E1_133_");
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Emergency Mapping");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
diag("Check Emergency Mapping details");
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Container name is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), "133")]'), 'Emergency Number is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), "E1_133_")]'), 'Emergency Prefix is correct');
diag("Edit Emergency Mapping Details");
$d->move_and_click('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[6]/div/a[2]', 'xpath', '//*[@id="emergency_mappings_table_filter"]//input');
$d->fill_element('//*[@id="code"]', 'xpath', "144");
$d->fill_element('//*[@id="prefix"]', 'xpath', "E2_144_");
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Emergency Mapping");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
diag("Check Emergency Mapping details");
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Container name is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), "144")]'), 'Emergency Number is correct');
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), "E2_144_")]'), 'Emergency Prefix is correct');
diag("Creating Domain to add Emergency Container");
$c->create_domain($domainstring, $resellername);
diag("Searching Domain");
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
ok($d->wait_for_text('//*[@id="Domain_table"]/tbody/tr[1]/td[contains(text(), "domain")]', $domainstring), "Domain was found");
$d->move_and_click('//*[@id="Domain_table"]//tr[1]//td//a[contains(text(), "Preferences")]', 'xpath', '//*[@id="Domain_table_filter"]/label/input');
diag("Open 'Number Manipulations'");
$d->find_element("Number Manipulations", 'link_text')->click();
$d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[contains(text(),"Number Manipulations")]'));
diag("Edit setting 'emergency_mapping_container'");
$d->scroll_to_element($d->find_element('//table//tr//td[contains(text(), "emergency_mapping_container")]'));
$d->move_and_click('//table//tr//td[contains(text(), "emergency_mapping_container")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "NAT and Media Flow Control")]');
$d->find_element('//*[@id="emergency_mapping_container"]/option[contains(text(), "' . $containername . '")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check if 'emergency_mapping_container' was applied");
ok($d->find_element_by_xpath('//table//tr//td[contains(text(), "emergency_mapping_container")]/../td/select/option[contains(text(), "' . $containername . '")][@selected="selected"]'), 'NCOS Level was applied');
diag("Open 'Internals'");
$d->find_element("Internals", 'link_text')->click();
$d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[contains(text(),"Internals")]'));
diag("Edit setting 'emergency_mode_enabled'");
$d->scroll_to_element($d->find_element('//table//tr//td[contains(text(), "emergency_mode_enabled")]'));
$d->move_and_click('//table//tr//td[contains(text(), "emergency_mode_enabled")]/../td//a[contains(text(), "Edit")]', 'xpath', '//table//tr//td[contains(text(), "call_deflection")]');
$d->select_if_unselected('//*[@id="emergency_mode_enabled"]');
$d->find_element('//*[@id="save"]')->click();
diag("Check if Setting was enabled");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "emergency_mode_enabled")]/../td//input[@checked="checked"]'), "Setting was enabled");
diag("Go to Emergency Mappings page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Emergency Mappings", 'link_text')->click();
diag("Trying to NOT delete Emergency Mapping");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
ok($d->wait_for_text('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[2]', $containername), 'Emergency mapping was found');
$d->move_and_click('//*[@id="emergency_mappings_table"]/tbody/tr/td[6]/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="emergency_mappings_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag("Check if Emergency Mapping is still here");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
ok($d->find_element_by_xpath('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Mapping is still here');
diag("Trying to delete Emergency Mapping");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
ok($d->wait_for_text('//*[@id="emergency_mappings_table"]/tbody/tr[1]/td[2]', $containername), 'Emergency mapping was found');
$d->move_and_click('//*[@id="emergency_mappings_table"]/tbody/tr/td[6]/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="emergency_mappings_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if Emergency Mapping was deleted");
$d->fill_element('//*[@id="emergency_mappings_table_filter"]/label/input', 'xpath', $containername);
ok($d->find_element_by_css('#emergency_mappings_table tr > td.dataTables_empty', 'css'), 'Emergency Mapping was deleted');
diag("Trying to NOT delete Emergency Container");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
ok($d->wait_for_text('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[3]', $containername), 'Emergency mapping was found');
$d->move_and_click('//*[@id="emergency_containers_table"]/tbody/tr/td[4]/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="emergency_containers_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag("Check if Emergency Container is still here");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
ok($d->find_element_by_xpath('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[contains(text(), ' . $containername . ')]'), 'Container is still here');
diag("Trying to delete Emergency Container");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
ok($d->wait_for_text('//*[@id="emergency_containers_table"]/tbody/tr[1]/td[3]', $containername), 'Emergency mapping was found');
$d->move_and_click('//*[@id="emergency_containers_table"]/tbody/tr/td[4]/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="emergency_containers_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if Emergency Container was deleted");
$d->fill_element('//*[@id="emergency_containers_table_filter"]/label/input', 'xpath', $containername);
ok($d->find_element_by_css('#emergency_containers_table tr > td.dataTables_empty', 'css'), 'Emergency Mapping was deleted');
$c->delete_domain($domainstring);
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_invoice {
my ($port) = @_;
@ -21,160 +22,183 @@ sub ctr_invoice {
my $billingname = ("billing" . int(rand(100000)) . "test");
my $customerid = ("id" . int(rand(100000)) . "ok");
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
$c->create_contact($contactmail, $resellername);
$c->create_billing_profile($billingname, $resellername);
$c->create_customer($customerid, $contactmail, $billingname);
diag("Search for Customer");
$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist');
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', $customerid);
ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $customerid), 'Customer found');
my $customernumber = $d->find_element('//*[@id="Customer_table"]/tbody/tr/td[1]')->get_text();
diag('Go to Invoice Templates page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Invoice Templates", 'link_text')->click();
diag("Trying to create a empty Invoice Template");
$d->find_element("Create Invoice Template", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input');
$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(), "Name field is required")]'));
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="name"]', 'xpath', $templatename);
$d->find_element('//*[@id="save"]')->click();
diag("Search for Template");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
diag("Check details");
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[2]', $resellername), 'Reseller is correct');
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[3]', $templatename), 'Name is correct');
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[4]', 'svg'), 'Type is correct');
diag("Try to edit Invoice Template Information");
$templatename = ("invoice" . int(rand(100000)) . "tem");
$d->move_and_click('//*[@id="InvoiceTemplate_table"]//tr[1]//td//a[contains(text(), "Edit Meta")]', 'xpath', '//*[@id="InvoiceTemplate_table_filter"]//input');
$d->fill_element('//*[@id="name"]', 'xpath', $templatename);
$d->find_element('//*[@id="save"]')->click();
diag("Search for Template");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
diag("Check details");
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[2]', $resellername), 'Reseller is correct');
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[3]', $templatename), 'Name is correct');
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[4]', 'svg'), 'Type is correct');
diag('Go to Invoices page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Invoices", 'link_text')->click();
diag("Trying to create a empty Invoice");
$d->find_element("Create Invoice", 'link_text')->click();
$d->unselect_if_selected('//*[@id="templateidtable"]/tbody/tr[1]/td[4]/input');
$d->unselect_if_selected('//*[@id="contractidtable"]/tbody/tr[1]/td[6]/input');
$d->find_element('//*[@id="save"]')->click();
diag("Check Error messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Customer field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invoice Period field is required")]'));
diag("Fill in Values");
$d->fill_element('//*[@id="templateidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#templateidtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="templateidtable_filter"]/label/input', 'xpath', $templatename);
ok($d->wait_for_text('//*[@id="templateidtable"]/tbody/tr[1]/td[3]', $templatename), 'Template was found');
$d->select_if_unselected('//*[@id="templateidtable"]/tbody/tr[1]/td[4]/input');
$d->scroll_to_element($d->find_element('//*[@id="contractidtable_filter"]/label/input'));
$d->fill_element('#contractidtable_filter input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#contractidtable tr > td.dataTables_empty', 'css'), 'Garbage test not found');
$d->fill_element('#contractidtable_filter input', 'css', $customerid);
ok($d->wait_for_text('//*[@id="contractidtable"]/tbody/tr[1]/td[4]', $customerid), 'Customer found');
$d->select_if_unselected('//*[@id="contractidtable"]/tbody/tr[1]/td[6]/input');
$d->find_element('//*[@id="period_datepicker"]')->click();
$d->find_element('//*[@id="ui-datepicker-div"]//button[contains(text(), "Today")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Search for Invoice");
$d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Invoice_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', $contactmail);
diag("Check details");
ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[2]', $customernumber), 'Customer# is correct');
ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[3]', $contactmail), 'Customer Email is correct');
diag("Trying to NOT delete Invoice");
$d->move_and_click('//*[@id="Invoice_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="Invoice_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag("Check if Invoice is still here");
$d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Invoice_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', $contactmail);
ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[2]', $customernumber), 'Invoice is still here');
ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[3]', $contactmail), 'Invoice is still here');
diag("Trying to delete Invoice");
$d->move_and_click('//*[@id="Invoice_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="Invoice_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if Invoice has been deleted");
$d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', $contactmail);
ok($d->find_element_by_css('#Invoice_table tr > td.dataTables_empty', 'css'), 'Invoice was deleted');
diag("Go to Invoice Templates page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Invoice Templates", 'link_text')->click();
diag("Trying to NOT delete Invoice Template");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
$d->move_and_click('//*[@id="InvoiceTemplate_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="InvoiceTemplate_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag("Check if Invoice Template was deleted");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[3]', $templatename), 'Template is still here');
diag("Trying to delete Invoice Template");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
$d->move_and_click('//*[@id="InvoiceTemplate_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="InvoiceTemplate_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if Invoice Template was deleted");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Invoice Template was deleted');
$c->delete_customer($customerid);
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
$c->delete_contact($contactmail);
$c->delete_billing_profile($billingname);
try {
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
$c->create_contact($contactmail, $resellername);
$c->create_billing_profile($billingname, $resellername);
$c->create_customer($customerid, $contactmail, $billingname);
diag("Search for Customer");
$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist');
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', $customerid);
ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $customerid), 'Customer found');
my $customernumber = $d->find_element('//*[@id="Customer_table"]/tbody/tr/td[1]')->get_text();
diag('Go to Invoice Templates page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Invoice Templates", 'link_text')->click();
diag("Trying to create a empty Invoice Template");
$d->find_element("Create Invoice Template", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input');
$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(), "Name field is required")]'));
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="name"]', 'xpath', $templatename);
$d->find_element('//*[@id="save"]')->click();
diag("Search for Template");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
diag("Check details");
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[2]', $resellername), 'Reseller is correct');
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[3]', $templatename), 'Name is correct');
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[4]', 'svg'), 'Type is correct');
diag("Try to edit Invoice Template Information");
$templatename = ("invoice" . int(rand(100000)) . "tem");
$d->move_and_click('//*[@id="InvoiceTemplate_table"]//tr[1]//td//a[contains(text(), "Edit Meta")]', 'xpath', '//*[@id="InvoiceTemplate_table_filter"]//input');
$d->fill_element('//*[@id="name"]', 'xpath', $templatename);
$d->find_element('//*[@id="save"]')->click();
diag("Search for Template");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
diag("Check details");
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[2]', $resellername), 'Reseller is correct');
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[3]', $templatename), 'Name is correct');
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[4]', 'svg'), 'Type is correct');
diag('Go to Invoices page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Invoices", 'link_text')->click();
diag("Trying to create a empty Invoice");
$d->find_element("Create Invoice", 'link_text')->click();
$d->unselect_if_selected('//*[@id="templateidtable"]/tbody/tr[1]/td[4]/input');
$d->unselect_if_selected('//*[@id="contractidtable"]/tbody/tr[1]/td[6]/input');
$d->find_element('//*[@id="save"]')->click();
diag("Check Error messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Customer field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invoice Period field is required")]'));
diag("Fill in Values");
$d->fill_element('//*[@id="templateidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#templateidtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="templateidtable_filter"]/label/input', 'xpath', $templatename);
ok($d->wait_for_text('//*[@id="templateidtable"]/tbody/tr[1]/td[3]', $templatename), 'Template was found');
$d->select_if_unselected('//*[@id="templateidtable"]/tbody/tr[1]/td[4]/input');
$d->scroll_to_element($d->find_element('//*[@id="contractidtable_filter"]/label/input'));
$d->fill_element('#contractidtable_filter input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#contractidtable tr > td.dataTables_empty', 'css'), 'Garbage test not found');
$d->fill_element('#contractidtable_filter input', 'css', $customerid);
ok($d->wait_for_text('//*[@id="contractidtable"]/tbody/tr[1]/td[4]', $customerid), 'Customer found');
$d->select_if_unselected('//*[@id="contractidtable"]/tbody/tr[1]/td[6]/input');
$d->find_element('//*[@id="period_datepicker"]')->click();
$d->find_element('//*[@id="ui-datepicker-div"]//button[contains(text(), "Today")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Search for Invoice");
$d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Invoice_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', $contactmail);
diag("Check details");
ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[2]', $customernumber), 'Customer# is correct');
ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[3]', $contactmail), 'Customer Email is correct');
diag("Trying to NOT delete Invoice");
$d->move_and_click('//*[@id="Invoice_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="Invoice_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag("Check if Invoice is still here");
$d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Invoice_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', $contactmail);
ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[2]', $customernumber), 'Invoice is still here');
ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[3]', $contactmail), 'Invoice is still here');
diag("Trying to delete Invoice");
$d->move_and_click('//*[@id="Invoice_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="Invoice_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if Invoice has been deleted");
$d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', $contactmail);
ok($d->find_element_by_css('#Invoice_table tr > td.dataTables_empty', 'css'), 'Invoice was deleted');
diag("Go to Invoice Templates page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Invoice Templates", 'link_text')->click();
diag("Trying to NOT delete Invoice Template");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
$d->move_and_click('//*[@id="InvoiceTemplate_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="InvoiceTemplate_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag("Check if Invoice Template was deleted");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[3]', $templatename), 'Template is still here');
diag("Trying to delete Invoice Template");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
$d->move_and_click('//*[@id="InvoiceTemplate_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="InvoiceTemplate_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if Invoice Template was deleted");
$d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename);
ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Invoice Template was deleted');
$c->delete_customer($customerid);
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
$c->delete_contact($contactmail);
$c->delete_billing_profile($billingname);
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_ncos {
my ($port) = @_;
@ -19,193 +20,215 @@ sub ctr_ncos {
my $ncosname = ("ncos" . int(rand(100000)) . "level");
my $domainstring = ("domain" . int(rand(100000)) . ".example.org");
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
diag('Go to NCOS interface');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("NCOS Levels", 'link_text')->click();
diag('Trying to create a empty NCOS Level');
$d->find_element("Create NCOS Level", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input', 'xpath');
$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")]'));
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('Search for our new 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);
diag("Check NCOS details");
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), ' . $ncosname . ')]'), 'NCOS name is correct');
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), "blacklist")]'), "NCOS mode is correct");
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), "This is a simple description")]'), "NCOS descriptions is correct");
diag('Edit NCOS');
$d->move_and_click('//*[@id="ncos_level_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="ncos_level_table_filter"]//input');
$ncosname = ("ncos" . int(rand(100000)) . "level");
$d->fill_element('//*[@id="level"]', 'xpath', $ncosname);
$d->find_element('//*[@id="mode"]/option[@value="whitelist"]')->click();
$d->fill_element('//*[@id="description"]', 'xpath', "This is a very simple description");
$d->find_element('//*[@id="save"]')->click();
diag('Search for 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);
diag("Check NCOS details");
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), ' . $ncosname . ')]'), 'NCOS name is correct');
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), "whitelist")]'), "NCOS mode is correct");
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), "This is a very simple description")]'), "NCOS descriptions is correct");
diag("Enter NCOS patterns");
$d->move_and_click('//*[@id="ncos_level_table"]/tbody/tr[1]/td/div/a[contains(text(), "Patterns")]', 'xpath', '//*[@id="ncos_level_table_filter"]/label/input');
diag("Create new pattern");
$d->find_element("Create Pattern Entry", 'link_text')->click();
diag("Click 'Save'");
$d->find_element('//*[@id="save"]')->click();
diag("Check Error messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Pattern field is required")]'));
diag("Enter pattern details");
$d->fill_element('//*[@id="pattern"]', 'xpath', '^439');
$d->fill_element('//*[@id="description"]', 'xpath', 'Austrian Premium Numbers');
$d->find_element('//*[@id="save"]')->click();
diag("Check pattern details");
ok($d->find_element_by_xpath('//*[@id="number_pattern_table"]/tbody/tr/td[contains(text(), "^439")]'), "Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="number_pattern_table"]/tbody/tr/td[contains(text(), "Austrian Premium Numbers")]'), "Description is correct");
diag("Edit NCOS Pattern");
$d->move_and_click('//*[@id="number_pattern_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="number_pattern_table_filter"]//input');
$d->fill_element('//*[@id="pattern"]', 'xpath', '^491');
$d->fill_element('//*[@id="description"]', 'xpath', 'German Premium Numbers');
$d->find_element('//*[@id="save"]')->click();
diag("Check pattern details");
ok($d->find_element_by_xpath('//*[@id="number_pattern_table"]/tbody/tr/td[contains(text(), "^491")]'), "Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="number_pattern_table"]/tbody/tr/td[contains(text(), "German Premium Numbers")]'), "Description is correct");
try {
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
diag('Go to NCOS interface');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("NCOS Levels", 'link_text')->click();
diag('Trying to create a empty NCOS Level');
$d->find_element("Create NCOS Level", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input', 'xpath');
$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")]'));
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('Search for our new 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);
diag("Check NCOS details");
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), ' . $ncosname . ')]'), 'NCOS name is correct');
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), "blacklist")]'), "NCOS mode is correct");
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), "This is a simple description")]'), "NCOS descriptions is correct");
diag('Edit NCOS');
$d->move_and_click('//*[@id="ncos_level_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="ncos_level_table_filter"]//input');
$ncosname = ("ncos" . int(rand(100000)) . "level");
$d->fill_element('//*[@id="level"]', 'xpath', $ncosname);
$d->find_element('//*[@id="mode"]/option[@value="whitelist"]')->click();
$d->fill_element('//*[@id="description"]', 'xpath', "This is a very simple description");
$d->find_element('//*[@id="save"]')->click();
diag('Search for 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);
diag("Check NCOS details");
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), ' . $resellername . ')]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), ' . $ncosname . ')]'), 'NCOS name is correct');
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), "whitelist")]'), "NCOS mode is correct");
ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contains(text(), "This is a very simple description")]'), "NCOS descriptions is correct");
diag("Enter NCOS patterns");
$d->move_and_click('//*[@id="ncos_level_table"]/tbody/tr[1]/td/div/a[contains(text(), "Patterns")]', 'xpath', '//*[@id="ncos_level_table_filter"]/label/input');
diag("Create new pattern");
$d->find_element("Create Pattern Entry", 'link_text')->click();
diag("Click 'Save'");
$d->find_element('//*[@id="save"]')->click();
diag("Check Error messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Pattern field is required")]'));
diag("Enter pattern details");
$d->fill_element('//*[@id="pattern"]', 'xpath', '^439');
$d->fill_element('//*[@id="description"]', 'xpath', 'Austrian Premium Numbers');
$d->find_element('//*[@id="save"]')->click();
diag("Check pattern details");
ok($d->find_element_by_xpath('//*[@id="number_pattern_table"]/tbody/tr/td[contains(text(), "^439")]'), "Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="number_pattern_table"]/tbody/tr/td[contains(text(), "Austrian Premium Numbers")]'), "Description is correct");
diag("Edit NCOS Pattern");
$d->move_and_click('//*[@id="number_pattern_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="number_pattern_table_filter"]//input');
$d->fill_element('//*[@id="pattern"]', 'xpath', '^491');
$d->fill_element('//*[@id="description"]', 'xpath', 'German Premium Numbers');
$d->find_element('//*[@id="save"]')->click();
diag("Check pattern details");
ok($d->find_element_by_xpath('//*[@id="number_pattern_table"]/tbody/tr/td[contains(text(), "^491")]'), "Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="number_pattern_table"]/tbody/tr/td[contains(text(), "German Premium Numbers")]'), "Description is correct");
=pod
diag("Create LNP entry");
$d->find_element("Create LNP Entry", 'link_text')->click();
diag("Create LNP entry");
$d->find_element("Create LNP Entry", 'link_text')->click();
diag("Enter LNP details");
$d->select_if_unselected('//*[@id="lnp_provideridtable"]/tbody/tr[1]/td[4]/input[@type="checkbox"]');
$d->fill_element('//*[@id="description"]', 'xpath', 'Rule for LNP Carrier 1');
$d->find_element('//*[@id="save"]')->click();
diag("Enter LNP details");
$d->select_if_unselected('//*[@id="lnp_provideridtable"]/tbody/tr[1]/td[4]/input[@type="checkbox"]');
$d->fill_element('//*[@id="description"]', 'xpath', 'Rule for LNP Carrier 1');
$d->find_element('//*[@id="save"]')->click();
diag("Check LNP details");
ok($d->find_element_by_xpath('//*[@id="lnp_carriers_table"]/tbody/tr/td[contains(text(), "Rule for LNP Carrier 1")]'), "Description is correct");
diag("Check LNP details");
ok($d->find_element_by_xpath('//*[@id="lnp_carriers_table"]/tbody/tr/td[contains(text(), "Rule for LNP Carrier 1")]'), "Description is correct");
=cut
diag("Edit NCOS settings");
$d->find_element('//*[@id="number_patterns_extra"]/div[2]/a')->click();
$d->select_if_unselected('//*[@id="local_ac"]');
$d->find_element('//*[@id="save"]')->click();
diag("Check if NCOS settings have been applied");
ok($d->find_element_by_xpath('//*[@id="local_ac"][@checked="checked"]'), 'Setting "Include local area code" was applied');
diag("Creating Domain to add NCOS Level");
$c->create_domain($domainstring, $resellername);
diag("Searching Domain");
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
ok($d->wait_for_text('//*[@id="Domain_table"]/tbody/tr[1]/td[contains(text(), "domain")]', $domainstring), "Domain was found");
$d->move_and_click('//*[@id="Domain_table"]//tr[1]//td//a[contains(text(), "Preferences")]', 'xpath', '//*[@id="Domain_table_filter"]/label/input');
diag("Open 'Call Blockings'");
$d->find_element("Call Blockings", 'link_text')->click();
$d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[contains(text(),"Call Blockings")]'));
diag("Edit setting 'NCOS'");
$d->move_and_click('//table//tr//td[contains(text(), "ncos")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(),"Call Blockings")]');
$d->find_element('//*[@id="ncos"]/option[contains(text(), "' . $ncosname . '")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check if NCOS Level was applied");
ok($d->find_element_by_xpath('//table//tr//td[contains(text(), "ncos")]/../td/select/option[contains(text(), "' . $ncosname . '")][@selected="selected"]'), 'NCOS Level was applied');
diag('Go back to NCOS interface');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("NCOS Levels", 'link_text')->click();
diag('Search for our new 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 was found');
diag('Go to NCOS settings');
$d->move_and_click('//*[@id="ncos_level_table"]/tbody/tr[1]/td/div/a[contains(text(), "Patterns")]', 'xpath', '//*[@id="ncos_level_table_filter"]/label/input');
diag("Delete NCOS Number pattern");
$d->move_and_click('//*[@id="number_pattern_table"]//tr//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="number_pattern_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if NCOS Number pattern was deleted");
ok($d->find_element_by_css('#number_pattern_table tr > td.dataTables_empty', 'css'), 'NCOS Number pattern was deleted');
diag("Edit NCOS settings");
$d->find_element('//*[@id="number_patterns_extra"]/div[2]/a')->click();
$d->select_if_unselected('//*[@id="local_ac"]');
$d->find_element('//*[@id="save"]')->click();
diag("Check if NCOS settings have been applied");
ok($d->find_element_by_xpath('//*[@id="local_ac"][@checked="checked"]'), 'Setting "Include local area code" was applied');
diag("Creating Domain to add NCOS Level");
$c->create_domain($domainstring, $resellername);
diag("Searching Domain");
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
ok($d->wait_for_text('//*[@id="Domain_table"]/tbody/tr[1]/td[contains(text(), "domain")]', $domainstring), "Domain was found");
$d->move_and_click('//*[@id="Domain_table"]//tr[1]//td//a[contains(text(), "Preferences")]', 'xpath', '//*[@id="Domain_table_filter"]/label/input');
diag("Open 'Call Blockings'");
$d->find_element("Call Blockings", 'link_text')->click();
$d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[contains(text(),"Call Blockings")]'));
diag("Edit setting 'NCOS'");
$d->move_and_click('//table//tr//td[contains(text(), "ncos")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(),"Call Blockings")]');
$d->find_element('//*[@id="ncos"]/option[contains(text(), "' . $ncosname . '")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check if NCOS Level was applied");
ok($d->find_element_by_xpath('//table//tr//td[contains(text(), "ncos")]/../td/select/option[contains(text(), "' . $ncosname . '")][@selected="selected"]'), 'NCOS Level was applied');
diag('Go back to NCOS interface');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("NCOS Levels", 'link_text')->click();
diag('Search for our new 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 was found');
diag('Go to NCOS settings');
$d->move_and_click('//*[@id="ncos_level_table"]/tbody/tr[1]/td/div/a[contains(text(), "Patterns")]', 'xpath', '//*[@id="ncos_level_table_filter"]/label/input');
diag("Delete NCOS Number pattern");
$d->move_and_click('//*[@id="number_pattern_table"]//tr//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="number_pattern_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if NCOS Number pattern was deleted");
ok($d->find_element_by_css('#number_pattern_table tr > td.dataTables_empty', 'css'), 'NCOS Number pattern was deleted');
=pod
diag("Delete LNP carrier");
$d->move_and_click('//*[@id="lnp_carriers_table"]//tr//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="lnp_carriers_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Delete LNP carrier");
$d->move_and_click('//*[@id="lnp_carriers_table"]//tr//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="lnp_carriers_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if LNP carrier was deleted");
ok($d->find_element_by_css('#lnp_carriers_table tr > td.dataTables_empty', 'css'), 'NCOS Number pattern was deleted');
diag("Check if LNP carrier was deleted");
ok($d->find_element_by_css('#lnp_carriers_table tr > td.dataTables_empty', 'css'), 'NCOS Number pattern was deleted');
=cut
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();
diag("Check if Entry is still here");
$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 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();
diag("Check if Entry was deleted");
$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');
$c->delete_domain($domainstring);
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
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();
diag("Check if Entry is still here");
$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 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();
diag("Check if Entry was deleted");
$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');
$c->delete_domain($domainstring);
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_peering {
my ($port) = @_;
@ -17,294 +18,317 @@ sub ctr_peering {
my $groupname = ("group" . int(rand(100000)) . "test");
my $servername = ("peering" . int(rand(100000)) . "server");
$c->login_ok();
diag("Go to Peerings page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Peerings", 'link_text')->click();
diag("Create a empty Peering Group");
$d->find_element('//*[@id="masthead"]//h2[contains(text(),"SIP Peering Groups")]');
my $peerings_uri = $d->get_current_url();
$d->find_element('Create Peering Group', 'link_text')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Contract field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
diag("Create a new Contract");
$d->find_element('//input[@type="button" and @value="Create Contract"]')->click();
$d->fill_element('//*[@id="contactidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#contactidtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="contactidtable_filter"]/label/input', 'xpath', 'default-system@default.invalid');
ok($d->wait_for_text('//*[@id="contactidtable"]/tbody/tr[1]/td[4]', 'default-system@default.invalid'), "Default Contact was found");
$d->select_if_unselected('//table[@id="contactidtable"]/tbody/tr[1]//input[@type="checkbox"]');
$d->scroll_to_element($d->find_element('//table[@id="billing_profileidtable"]'));
$d->select_if_unselected('//table[@id="billing_profileidtable"]/tbody/tr[1]//input[@type="checkbox"]');
$d->find_element('//*[@id="status"]/option[@value="active"]')->click();
$d->find_element('//*[@id="save"]')->click();
ok($d->find_text('Create Peering Group'), 'Succesfully went back to previous form'); # Should go back to prev form
diag("Continue creating a Peering Group");
$d->fill_element('#name', 'css', $groupname);
$d->fill_element('#description', 'css', 'A group created for testing purposes');
$d->find_element('//*[@id="priority"]/option[@value="3"]')->click();
$d->select_if_unselected('//table[@id="contractidtable"]/tbody/tr[1]//input[@type="checkbox"]');
$d->find_element('#save', 'css')->click();
diag("Search for the newly created Peering Group");
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#sip_peering_group_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', $groupname);
diag("Check Peering Group Details");
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[2]', 'default-system@default.invalid'), 'Contact is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[3]', $groupname), 'Name is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[4]', '3'), 'Priority is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[5]', 'A group created for testing purposes'), 'Description is correct');
diag("Edit Peering Group");
$groupname = ("group" . int(rand(100000)) . "test");
$d->move_and_click('//*[@id="sip_peering_group_table"]/tbody/tr[1]//td//div//a[contains(text(), "Edit")]', 'xpath');
$d->fill_element('#name', 'css', $groupname);
$d->fill_element('#description', 'css', 'A group created for very testing purposes');
$d->find_element('//*[@id="priority"]/option[@value="1"]')->click();
$d->find_element('#save', 'css')->click();
diag("Search for the newly created Peering Group");
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#sip_peering_group_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', $groupname);
diag("Check Peering Group Details");
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[2]', 'default-system@default.invalid'), 'Contact is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[3]', $groupname), 'Name is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[4]', '1'), 'Priority is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[5]', 'A group created for very testing purposes'), 'Description is correct');
diag("Go to Details of the Peering Group");
$d->move_and_click('//*[@id="sip_peering_group_table"]/tbody/tr[1]//td//div//a[contains(text(), "Details")]', 'xpath');
diag("Create empty Outbound Peering Rule");
$d->find_element('//a[contains(text(),"Create Outbound Peering Rule")]')->click();
$d->find_element('#save', 'css')->click();
diag("Check if it was created");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Peering rule successfully created")]'), "Text appears");
diag("Delete empty Outbound Peering Rule");
ok($d->move_and_click('//*[@id="PeeringRules_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="PeeringRules_table_filter"]//input'));
$d->find_element('#dataConfirmOK', 'css')->click();
diag("Create Outbound Peering Rule");
$d->find_element('//a[contains(text(),"Create Outbound Peering Rule")]')->click();
$d->fill_element('#callee_prefix', 'css', '43');
$d->fill_element('#callee_pattern', 'css', '^sip');
$d->fill_element('#caller_pattern', 'css', '999');
$d->fill_element('#description', 'css', 'for testing purposes');
$d->find_element('#save', 'css')->click();
diag("Check Outbound Peering Rule Details");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "43")]'), "Prefix is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "^sip")]'), "Callee Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "999")]'), "Caller Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "for testing purposes")]'), "Description is correct");
diag("Edit Outbound Peering Rule Details");
$d->move_and_click('//*[@id="PeeringRules_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="PeeringRules_table_filter"]//input');
$d->fill_element('#callee_prefix', 'css', '49');
$d->fill_element('#callee_pattern', 'css', '^sup');
$d->fill_element('#caller_pattern', 'css', '888');
$d->fill_element('#description', 'css', 'for very testing purposes');
$d->find_element('#save', 'css')->click();
diag("Check Outbound Peering Rule Details");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "49")]'), "Prefix is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "^sup")]'), "Callee Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "888")]'), "Caller Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "for very testing purposes")]'), "Description is correct");
diag("Create empty Inbound Peering Rule");
$d->find_element('//a[contains(text(),"Create Inbound Peering Rule")]')->click();
$d->find_element('#save', 'css')->click();
diag("Check if creation failed");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Failed to create inbound peering rule")]'), "Text appears");
diag("Create Inbound Peering Rule");
$d->find_element('//a[contains(text(),"Create Inbound Peering Rule")]')->click();
$d->fill_element('//*[@id="pattern"]', 'xpath', '^sip');
$d->fill_element('//*[@id="reject_code"]', 'xpath', '403');
$d->fill_element('//*[@id="reject_reason"]', 'xpath', 'forbidden');
$d->find_element('#save', 'css')->click();
diag("Check Inbound Peering Rule Details");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "^sip")]'), "Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "403")]'), "Reject Code is correct");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "forbidden")]'), "Reject Reason is correct");
diag("Edit Inbound Peering Rule Details");
$d->scroll_to_element($d->find_element('//a[contains(text(),"Create Inbound Peering Rule")]'));
$d->move_and_click('//*[@id="InboundPeeringRules_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="InboundPeeringRules_table_filter"]//input');
$d->fill_element('//*[@id="pattern"]', 'xpath', '^sup');
$d->fill_element('//*[@id="reject_code"]', 'xpath', '404');
$d->fill_element('//*[@id="reject_reason"]', 'xpath', 'not found');
$d->find_element('#save', 'css')->click();
diag("Check Inbound Peering Rule Details");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "^sup")]'), "Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "404")]'), "Reject Code is correct");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "not found")]'), "Reject Reason is correct");
diag("Create a empty Peering Server");
$d->find_element('//a[contains(text(),"Create Peering Server")]')->click();
$d->find_element('#save', 'css')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "IP Address field is required")]'));
diag("Fill in values");
$d->fill_element('#name', 'css', $servername);
$d->fill_element('#ip', 'css', '10.0.0.100');
$d->fill_element('#host', 'css', 'sipwise.com');
$d->find_element('#save', 'css')->click();
ok($d->find_text('Peering server successfully created'), 'Text "Peering server successfully created" appears');
my $server_rules_uri = $d->get_current_url();
diag("Check Peering Server Details");
ok($d->wait_for_text('//*[@id="peering_servers_table"]/tbody/tr/td[2]', $servername), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="peering_servers_table"]/tbody/tr/td[contains(text(), "10.0.0.100")]'), "IP is correct");
ok($d->find_element_by_xpath('//*[@id="peering_servers_table"]/tbody/tr/td[contains(text(), "sipwise.com")]'), "Host is correct");
diag("Edit Peering Server Details");
$servername = ("peering" . int(rand(100000)) . "server");
$d->move_and_click('//*[@id="peering_servers_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="peering_servers_table_filter"]//input');
$d->fill_element('#name', 'css', $servername);
$d->fill_element('#ip', 'css', '10.0.1.101');
$d->fill_element('#host', 'css', 'google.at');
$d->find_element('#save', 'css')->click();
diag("Check Peering Server Details");
ok($d->wait_for_text('//*[@id="peering_servers_table"]/tbody/tr/td[2]', $servername), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="peering_servers_table"]/tbody/tr/td[contains(text(), "10.0.1.101")]'), "IP is correct");
ok($d->find_element_by_xpath('//*[@id="peering_servers_table"]/tbody/tr/td[contains(text(), "google.at")]'), "Host is correct");
diag('Go into Peering Server Preferences');
$d->fill_element('#peering_servers_table_filter input', 'css', 'thisshouldnotexist');
$d->find_element('#peering_servers_table tr > td.dataTables_empty', 'css');
$d->fill_element('#peering_servers_table_filter input', 'css', $servername);
ok($d->wait_for_text('//*[@id="peering_servers_table"]/tbody/tr[1]/td[2]', $servername), 'Peering Server has been found');
$d->move_and_click('//*[@id="peering_servers_table"]/tbody/tr[1]//td//div//a[contains(text(), "Preferences")]', 'xpath', '//*[@id="peering_servers_table_filter"]//input');
diag('Open the tab "Number Manipulations"');
$d->find_element("Number Manipulations", 'link_text')->click();
diag("Click edit for the preference inbound_upn");
$d->move_and_click('//table//td[contains(text(), "inbound_upn")]/..//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Number Manipulation")]');
diag('Change to "P-Asserted-Identity');
$d->find_element('//*[@id="inbound_upn"]/option[@value="pai_user"]')->click();
$d->find_element('#save', 'css')->click();
diag('Check if value has been applied');
ok($d->find_text('Preference inbound_upn successfully updated'), 'Text "Preference inbound_upn successfully updated" appears');
ok($d->wait_for_text('//table//td[contains(text(), "inbound_upn")]/../td/select/option[@selected="selected"]', "P-Asserted-Identity"), "Value has been applied");
diag('Open the tab "Remote Authentication"');
$d->scroll_to_element($d->find_element("Remote Authentication", 'link_text'));
$d->find_element("Remote Authentication", 'link_text')->click();
diag('Edit peer_auth_user');
$d->move_and_click('//table/tbody/tr/td[contains(text(), "peer_auth_user")]/../td/div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Remote Authentication")]');
$d->fill_element('//*[@id="peer_auth_user"]', 'xpath', 'peeruser1');
$d->find_element('#save', 'css')->click();
diag('Check if peer_auth_user value has been set');
ok($d->find_text('Preference peer_auth_user successfully updated'), 'Text "Preference peer_auth_user successfully updated" appears');
$d->find_element("Remote Authentication", 'link_text')->click();
ok($d->wait_for_text('//table/tbody/tr/td[contains(text(), "peer_auth_user")]/../td[4]', 'peeruser1'), 'peer_auth_user value has been set');
diag('Edit peer_auth_pass');
$d->move_and_click('//table/tbody/tr/td[contains(text(), "peer_auth_pass")]/../td/div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Remote Authentication")]');
$d->fill_element('//*[@id="peer_auth_pass"]', 'xpath', 'peerpass1');
$d->find_element('#save', 'css')->click();
diag('Check if peer_auth_pass value has been set');
ok($d->find_text('Preference peer_auth_pass successfully updated'), 'Text "Preference peer_auth_pass successfully updated" appears');
$d->find_element("Remote Authentication", 'link_text')->click();
ok($d->wait_for_text('//table/tbody/tr/td[contains(text(), "peer_auth_pass")]/../td[4]', 'peerpass1'), 'peer_auth_pass value has been set');
diag('Edit peer_auth_realm');
$d->move_and_click('//table/tbody/tr/td[contains(text(), "peer_auth_realm")]/../td/div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Remote Authentication")]');
$d->fill_element('//*[@id="peer_auth_realm"]', 'xpath', 'testpeering.com');
$d->find_element('#save', 'css')->click();
diag('Check if peer_auth_realm value has been set');
ok($d->find_text('Preference peer_auth_realm successfully updated'), 'Text "Preference peer_auth_realm successfully updated" appears');
$d->find_element("Remote Authentication", 'link_text')->click();
ok($d->wait_for_text('//table/tbody/tr/td[contains(text(), "peer_auth_realm")]/../td[4]', 'testpeering.com'), 'peer_auth_realm value has been set');
diag("Go back to Servers/Rules");
$d->get($server_rules_uri);
diag("Delete mytestserver");
$d->fill_element('#peering_servers_table_filter input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#peering_servers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#peering_servers_table_filter input', 'css', $servername);
ok($d->wait_for_text('//*[@id="peering_servers_table"]/tbody/tr/td[2]', $servername), "mytestserver was found");
$d->move_and_click('//*[@id="peering_servers_table"]/tbody/tr[1]//td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="peering_servers_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
ok($d->find_text("successfully deleted"), 'Text "successfully deleted" appears');
diag("Delete the Outbound Peering Rule");
$d->fill_element('#PeeringRules_table_filter input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#PeeringRules_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#PeeringRules_table_filter input', 'css', 'for very testing purposes');
ok($d->wait_for_text('//*[@id="PeeringRules_table"]/tbody/tr/td[5]', 'for very testing purposes'), "Outbound Peering Rule was found");
$d->move_and_click('//*[@id="PeeringRules_table"]/tbody/tr[1]//td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="PeeringRules_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
ok($d->find_text("successfully deleted"), 'Text "successfully deleted" appears');
diag("Delete the Inbound Peering Rule");
$d->scroll_to_element($d->find_element('//a[contains(text(),"Create Inbound Peering Rule")]'));
$d->fill_element('#InboundPeeringRules_table_filter input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#InboundPeeringRules_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#InboundPeeringRules_table_filter input', 'css', 'not found');
ok($d->wait_for_text('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[6]', 'not found'), "Inbound Peering Rule was found");
$d->move_and_click('//*[@id="InboundPeeringRules_table"]/tbody/tr[1]//td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="InboundPeeringRules_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
ok($d->find_text("successfully deleted"), 'Text "successfully deleted" appears');
diag('Go back to "SIP Peering Groups".');
$d->get($peerings_uri);
diag('Trying to NOT delete Testinggroup');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#sip_peering_group_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', $groupname);
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[3]', $groupname), 'Testing Group was found');
$d->move_and_click('//*[@id="sip_peering_group_table"]/tbody/tr[1]//td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="sip_peering_group_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmCancel', 'css')->click();
diag('Checking if Testing Group has been deleted');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', $groupname);
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[3]', $groupname), 'Testinggroup is still here');
diag('Trying to delete Testinggroup');
$d->move_and_click('//*[@id="sip_peering_group_table"]/tbody/tr[1]//td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="sip_peering_group_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
ok($d->find_text("successfully deleted"), 'Text "successfully deleted" appears');
diag('Checking if Testing Group has been deleted');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', $groupname);
ok($d->find_element_by_css('#sip_peering_group_table tr > td.dataTables_empty', 'css'), 'Testing Group was deleted');
try {
$c->login_ok();
diag("Go to Peerings page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Peerings", 'link_text')->click();
diag("Create a empty Peering Group");
$d->find_element('//*[@id="masthead"]//h2[contains(text(),"SIP Peering Groups")]');
my $peerings_uri = $d->get_current_url();
$d->find_element('Create Peering Group', 'link_text')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Contract field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
diag("Create a new Contract");
$d->find_element('//input[@type="button" and @value="Create Contract"]')->click();
$d->fill_element('//*[@id="contactidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#contactidtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="contactidtable_filter"]/label/input', 'xpath', 'default-system@default.invalid');
ok($d->wait_for_text('//*[@id="contactidtable"]/tbody/tr[1]/td[4]', 'default-system@default.invalid'), "Default Contact was found");
$d->select_if_unselected('//table[@id="contactidtable"]/tbody/tr[1]//input[@type="checkbox"]');
$d->scroll_to_element($d->find_element('//table[@id="billing_profileidtable"]'));
$d->select_if_unselected('//table[@id="billing_profileidtable"]/tbody/tr[1]//input[@type="checkbox"]');
$d->find_element('//*[@id="status"]/option[@value="active"]')->click();
$d->find_element('//*[@id="save"]')->click();
ok($d->find_text('Create Peering Group'), 'Succesfully went back to previous form'); # Should go back to prev form
diag("Continue creating a Peering Group");
$d->fill_element('#name', 'css', $groupname);
$d->fill_element('#description', 'css', 'A group created for testing purposes');
$d->find_element('//*[@id="priority"]/option[@value="3"]')->click();
$d->select_if_unselected('//table[@id="contractidtable"]/tbody/tr[1]//input[@type="checkbox"]');
$d->find_element('#save', 'css')->click();
diag("Search for the newly created Peering Group");
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#sip_peering_group_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', $groupname);
diag("Check Peering Group Details");
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[2]', 'default-system@default.invalid'), 'Contact is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[3]', $groupname), 'Name is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[4]', '3'), 'Priority is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[5]', 'A group created for testing purposes'), 'Description is correct');
diag("Edit Peering Group");
$groupname = ("group" . int(rand(100000)) . "test");
$d->move_and_click('//*[@id="sip_peering_group_table"]/tbody/tr[1]//td//div//a[contains(text(), "Edit")]', 'xpath');
$d->fill_element('#name', 'css', $groupname);
$d->fill_element('#description', 'css', 'A group created for very testing purposes');
$d->find_element('//*[@id="priority"]/option[@value="1"]')->click();
$d->find_element('#save', 'css')->click();
diag("Search for the newly created Peering Group");
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#sip_peering_group_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', $groupname);
diag("Check Peering Group Details");
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[2]', 'default-system@default.invalid'), 'Contact is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[3]', $groupname), 'Name is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[4]', '1'), 'Priority is correct');
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[5]', 'A group created for very testing purposes'), 'Description is correct');
diag("Go to Details of the Peering Group");
$d->move_and_click('//*[@id="sip_peering_group_table"]/tbody/tr[1]//td//div//a[contains(text(), "Details")]', 'xpath');
diag("Create empty Outbound Peering Rule");
$d->find_element('//a[contains(text(),"Create Outbound Peering Rule")]')->click();
$d->find_element('#save', 'css')->click();
diag("Check if it was created");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Peering rule successfully created")]'), "Text appears");
diag("Delete empty Outbound Peering Rule");
ok($d->move_and_click('//*[@id="PeeringRules_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="PeeringRules_table_filter"]//input'));
$d->find_element('#dataConfirmOK', 'css')->click();
diag("Create Outbound Peering Rule");
$d->find_element('//a[contains(text(),"Create Outbound Peering Rule")]')->click();
$d->fill_element('#callee_prefix', 'css', '43');
$d->fill_element('#callee_pattern', 'css', '^sip');
$d->fill_element('#caller_pattern', 'css', '999');
$d->fill_element('#description', 'css', 'for testing purposes');
$d->find_element('#save', 'css')->click();
diag("Check Outbound Peering Rule Details");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "43")]'), "Prefix is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "^sip")]'), "Callee Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "999")]'), "Caller Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "for testing purposes")]'), "Description is correct");
diag("Edit Outbound Peering Rule Details");
$d->move_and_click('//*[@id="PeeringRules_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="PeeringRules_table_filter"]//input');
$d->fill_element('#callee_prefix', 'css', '49');
$d->fill_element('#callee_pattern', 'css', '^sup');
$d->fill_element('#caller_pattern', 'css', '888');
$d->fill_element('#description', 'css', 'for very testing purposes');
$d->find_element('#save', 'css')->click();
diag("Check Outbound Peering Rule Details");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "49")]'), "Prefix is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "^sup")]'), "Callee Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "888")]'), "Caller Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="PeeringRules_table"]/tbody/tr/td[contains(text(), "for very testing purposes")]'), "Description is correct");
diag("Create empty Inbound Peering Rule");
$d->find_element('//a[contains(text(),"Create Inbound Peering Rule")]')->click();
$d->find_element('#save', 'css')->click();
diag("Check if creation failed");
ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(text(), "Failed to create inbound peering rule")]'), "Text appears");
diag("Create Inbound Peering Rule");
$d->find_element('//a[contains(text(),"Create Inbound Peering Rule")]')->click();
$d->fill_element('//*[@id="pattern"]', 'xpath', '^sip');
$d->fill_element('//*[@id="reject_code"]', 'xpath', '403');
$d->fill_element('//*[@id="reject_reason"]', 'xpath', 'forbidden');
$d->find_element('#save', 'css')->click();
diag("Check Inbound Peering Rule Details");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "^sip")]'), "Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "403")]'), "Reject Code is correct");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "forbidden")]'), "Reject Reason is correct");
diag("Edit Inbound Peering Rule Details");
$d->scroll_to_element($d->find_element('//a[contains(text(),"Create Inbound Peering Rule")]'));
$d->move_and_click('//*[@id="InboundPeeringRules_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="InboundPeeringRules_table_filter"]//input');
$d->fill_element('//*[@id="pattern"]', 'xpath', '^sup');
$d->fill_element('//*[@id="reject_code"]', 'xpath', '404');
$d->fill_element('//*[@id="reject_reason"]', 'xpath', 'not found');
$d->find_element('#save', 'css')->click();
diag("Check Inbound Peering Rule Details");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "^sup")]'), "Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "404")]'), "Reject Code is correct");
ok($d->find_element_by_xpath('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[contains(text(), "not found")]'), "Reject Reason is correct");
diag("Create a empty Peering Server");
$d->find_element('//a[contains(text(),"Create Peering Server")]')->click();
$d->find_element('#save', 'css')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "IP Address field is required")]'));
diag("Fill in values");
$d->fill_element('#name', 'css', $servername);
$d->fill_element('#ip', 'css', '10.0.0.100');
$d->fill_element('#host', 'css', 'sipwise.com');
$d->find_element('#save', 'css')->click();
ok($d->find_text('Peering server successfully created'), 'Text "Peering server successfully created" appears');
my $server_rules_uri = $d->get_current_url();
diag("Check Peering Server Details");
ok($d->wait_for_text('//*[@id="peering_servers_table"]/tbody/tr/td[2]', $servername), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="peering_servers_table"]/tbody/tr/td[contains(text(), "10.0.0.100")]'), "IP is correct");
ok($d->find_element_by_xpath('//*[@id="peering_servers_table"]/tbody/tr/td[contains(text(), "sipwise.com")]'), "Host is correct");
diag("Edit Peering Server Details");
$servername = ("peering" . int(rand(100000)) . "server");
$d->move_and_click('//*[@id="peering_servers_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="peering_servers_table_filter"]//input');
$d->fill_element('#name', 'css', $servername);
$d->fill_element('#ip', 'css', '10.0.1.101');
$d->fill_element('#host', 'css', 'google.at');
$d->find_element('#save', 'css')->click();
diag("Check Peering Server Details");
ok($d->wait_for_text('//*[@id="peering_servers_table"]/tbody/tr/td[2]', $servername), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="peering_servers_table"]/tbody/tr/td[contains(text(), "10.0.1.101")]'), "IP is correct");
ok($d->find_element_by_xpath('//*[@id="peering_servers_table"]/tbody/tr/td[contains(text(), "google.at")]'), "Host is correct");
diag('Go into Peering Server Preferences');
$d->fill_element('#peering_servers_table_filter input', 'css', 'thisshouldnotexist');
$d->find_element('#peering_servers_table tr > td.dataTables_empty', 'css');
$d->fill_element('#peering_servers_table_filter input', 'css', $servername);
ok($d->wait_for_text('//*[@id="peering_servers_table"]/tbody/tr[1]/td[2]', $servername), 'Peering Server has been found');
$d->move_and_click('//*[@id="peering_servers_table"]/tbody/tr[1]//td//div//a[contains(text(), "Preferences")]', 'xpath', '//*[@id="peering_servers_table_filter"]//input');
diag('Open the tab "Number Manipulations"');
$d->find_element("Number Manipulations", 'link_text')->click();
diag("Click edit for the preference inbound_upn");
$d->move_and_click('//table//td[contains(text(), "inbound_upn")]/..//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Number Manipulation")]');
diag('Change to "P-Asserted-Identity');
$d->find_element('//*[@id="inbound_upn"]/option[@value="pai_user"]')->click();
$d->find_element('#save', 'css')->click();
diag('Check if value has been applied');
ok($d->find_text('Preference inbound_upn successfully updated'), 'Text "Preference inbound_upn successfully updated" appears');
ok($d->wait_for_text('//table//td[contains(text(), "inbound_upn")]/../td/select/option[@selected="selected"]', "P-Asserted-Identity"), "Value has been applied");
diag('Open the tab "Remote Authentication"');
$d->scroll_to_element($d->find_element("Remote Authentication", 'link_text'));
$d->find_element("Remote Authentication", 'link_text')->click();
diag('Edit peer_auth_user');
$d->move_and_click('//table/tbody/tr/td[contains(text(), "peer_auth_user")]/../td/div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Remote Authentication")]');
$d->fill_element('//*[@id="peer_auth_user"]', 'xpath', 'peeruser1');
$d->find_element('#save', 'css')->click();
diag('Check if peer_auth_user value has been set');
ok($d->find_text('Preference peer_auth_user successfully updated'), 'Text "Preference peer_auth_user successfully updated" appears');
$d->find_element("Remote Authentication", 'link_text')->click();
ok($d->wait_for_text('//table/tbody/tr/td[contains(text(), "peer_auth_user")]/../td[4]', 'peeruser1'), 'peer_auth_user value has been set');
diag('Edit peer_auth_pass');
$d->move_and_click('//table/tbody/tr/td[contains(text(), "peer_auth_pass")]/../td/div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Remote Authentication")]');
$d->fill_element('//*[@id="peer_auth_pass"]', 'xpath', 'peerpass1');
$d->find_element('#save', 'css')->click();
diag('Check if peer_auth_pass value has been set');
ok($d->find_text('Preference peer_auth_pass successfully updated'), 'Text "Preference peer_auth_pass successfully updated" appears');
$d->find_element("Remote Authentication", 'link_text')->click();
ok($d->wait_for_text('//table/tbody/tr/td[contains(text(), "peer_auth_pass")]/../td[4]', 'peerpass1'), 'peer_auth_pass value has been set');
diag('Edit peer_auth_realm');
$d->move_and_click('//table/tbody/tr/td[contains(text(), "peer_auth_realm")]/../td/div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Remote Authentication")]');
$d->fill_element('//*[@id="peer_auth_realm"]', 'xpath', 'testpeering.com');
$d->find_element('#save', 'css')->click();
diag('Check if peer_auth_realm value has been set');
ok($d->find_text('Preference peer_auth_realm successfully updated'), 'Text "Preference peer_auth_realm successfully updated" appears');
$d->find_element("Remote Authentication", 'link_text')->click();
ok($d->wait_for_text('//table/tbody/tr/td[contains(text(), "peer_auth_realm")]/../td[4]', 'testpeering.com'), 'peer_auth_realm value has been set');
diag("Go back to Servers/Rules");
$d->get($server_rules_uri);
diag("Delete mytestserver");
$d->fill_element('#peering_servers_table_filter input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#peering_servers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#peering_servers_table_filter input', 'css', $servername);
ok($d->wait_for_text('//*[@id="peering_servers_table"]/tbody/tr/td[2]', $servername), "mytestserver was found");
$d->move_and_click('//*[@id="peering_servers_table"]/tbody/tr[1]//td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="peering_servers_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
ok($d->find_text("successfully deleted"), 'Text "successfully deleted" appears');
diag("Delete the Outbound Peering Rule");
$d->fill_element('#PeeringRules_table_filter input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#PeeringRules_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#PeeringRules_table_filter input', 'css', 'for very testing purposes');
ok($d->wait_for_text('//*[@id="PeeringRules_table"]/tbody/tr/td[5]', 'for very testing purposes'), "Outbound Peering Rule was found");
$d->move_and_click('//*[@id="PeeringRules_table"]/tbody/tr[1]//td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="PeeringRules_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
ok($d->find_text("successfully deleted"), 'Text "successfully deleted" appears');
diag("Delete the Inbound Peering Rule");
$d->scroll_to_element($d->find_element('//a[contains(text(),"Create Inbound Peering Rule")]'));
$d->fill_element('#InboundPeeringRules_table_filter input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#InboundPeeringRules_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#InboundPeeringRules_table_filter input', 'css', 'not found');
ok($d->wait_for_text('//*[@id="InboundPeeringRules_table"]/tbody/tr/td[6]', 'not found'), "Inbound Peering Rule was found");
$d->move_and_click('//*[@id="InboundPeeringRules_table"]/tbody/tr[1]//td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="InboundPeeringRules_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
ok($d->find_text("successfully deleted"), 'Text "successfully deleted" appears');
diag('Go back to "SIP Peering Groups".');
$d->get($peerings_uri);
diag('Trying to NOT delete Testinggroup');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#sip_peering_group_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', $groupname);
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[3]', $groupname), 'Testing Group was found');
$d->move_and_click('//*[@id="sip_peering_group_table"]/tbody/tr[1]//td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="sip_peering_group_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmCancel', 'css')->click();
diag('Checking if Testing Group has been deleted');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', $groupname);
ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[3]', $groupname), 'Testinggroup is still here');
diag('Trying to delete Testinggroup');
$d->move_and_click('//*[@id="sip_peering_group_table"]/tbody/tr[1]//td//div//a[contains(text(), "Delete")]', 'xpath', '//*[@id="sip_peering_group_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
ok($d->find_text("successfully deleted"), 'Text "successfully deleted" appears');
diag('Checking if Testing Group has been deleted');
$d->fill_element('//*[@id="sip_peering_group_table_filter"]/label/input', 'xpath', $groupname);
ok($d->find_element_by_css('#sip_peering_group_table tr > td.dataTables_empty', 'css'), 'Testing Group was deleted');
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_reseller {
my ($port) = @_;
@ -18,202 +19,225 @@ sub ctr_reseller {
my $contractid = ("contract" . int(rand(100000)) . "test");
my $templatename = ("template" . int(rand(100000)) . "mail");
$c->login_ok();
$c->create_reseller_contract($contractid);
diag('Go to reseller page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element('Resellers', 'link_text')->click();
diag('Try to create a empty reseller');
$d->find_element('Create Reseller', 'link_text')->click();
$d->unselect_if_selected('//*[@id="contractidtable"]/tbody/tr/td[5]/input');
$d->find_element('//*[@id="save"]')->click();
diag('Check Error Messages');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Contract field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
diag('Create a legit reseller');
$d->find_element('#mod_close', 'css')->click();
$c->create_reseller($resellername, $contractid);
diag("Search our new reseller");
$d->fill_element('#Resellers_table_filter label input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#Resellers_table_filter label input', 'css', $resellername);
diag("Check Reseller Details");
ok($d->wait_for_text('//*[@id="Resellers_table"]/tbody/tr[1]/td[3]', $resellername), 'Reseller Name is correct');
ok($d->find_element_by_xpath('//*[@id="Resellers_table"]//tr//td[contains(text(), "active")]'), 'Status is correct');
diag("Click Edit on our newly created reseller");
$d->move_and_click('//*[@id="Resellers_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Resellers_table_filter"]//input');
diag("Edit name and status");
$resellername = ("reseller" . int(rand(100000)) . "test");
$d->fill_element('//*[@id="name"]', 'xpath', $resellername);
$d->find_element('//*[@id="status"]/option[@value="locked"]')->click();
$d->find_element('#save', 'css')->click();
diag("Search our new reseller");
$d->fill_element('#Resellers_table_filter label input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#Resellers_table_filter label input', 'css', $resellername);
diag("Check Reseller Details");
ok($d->wait_for_text('//*[@id="Resellers_table"]/tbody/tr[1]/td[3]', $resellername), 'Reseller Name is correct');
ok($d->find_element_by_xpath('//*[@id="Resellers_table"]//tr//td[contains(text(), "locked")]'), 'Status is correct');
diag("Click Details on our newly created reseller");
$d->move_and_click('//*[@id="Resellers_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Resellers_table_filter"]//input');
diag("Create a empty Phonebook entry");
$d->scroll_to_element($d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]'));
$d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element("Create Phonebook Entry", 'link_text'));
$d->find_element("Create Phonebook Entry", 'link_text')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Number field is required")]'));
diag("Fill in values");
$d->fill_element('//*[@id="name"]', 'xpath', 'testname');
$d->fill_element('//*[@id="number"]', 'xpath', '0123456789');
$d->find_element('//*[@id="save"]')->click();
diag("Searching Phonebook entry");
$d->scroll_to_element($d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]'));
$d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element("Create Phonebook Entry", 'link_text'));
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#phonebook_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'testname');
diag("Checking Phonebook entry details");
ok($d->wait_for_text('//*[@id="phonebook_table"]/tbody/tr/td[2]', 'testname'), 'Name is correct');
ok($d->wait_for_text('//*[@id="phonebook_table"]/tbody/tr/td[3]', '0123456789'), 'Number is correct');
diag("Edit Phonebook entry");
$d->move_and_click('//*[@id="phonebook_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="phonebook_table_filter"]/label/input');
$d->fill_element('//*[@id="name"]', 'xpath', 'newtestname');
$d->fill_element('//*[@id="number"]', 'xpath', '0987654321');
$d->find_element('//*[@id="save"]')->click();
diag("Searching Phonebook entry");
$d->scroll_to_element($d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]'));
$d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element("Create Phonebook Entry", 'link_text'));
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#phonebook_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'newtestname');
diag("Checking Phonebook entry details");
ok($d->wait_for_text('//*[@id="phonebook_table"]/tbody/tr/td[2]', 'newtestname'), 'Name is correct');
ok($d->wait_for_text('//*[@id="phonebook_table"]/tbody/tr/td[3]', '0987654321'), 'Number is correct');
diag('Go to Email Templates');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Email Templates", 'link_text')->click();
diag('Trying to create a empty Template');
$d->find_element("Create Email Template", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]//tr[1]/td[5]/input');
$d->find_element('//*[@id="save"]')->click();
diag('Check Error Messages');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "From Email Address field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Subject field is required")]'));
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');
$d->fill_element('//*[@id="name"]', 'xpath', $templatename);
$d->fill_element('//*[@id="from_email"]', 'xpath', 'default@mail.test');
$d->fill_element('//*[@id="subject"]', 'xpath', 'Testing Stuff');
$d->fill_element('//*[@id="body"]', 'xpath', 'Howdy Buddy, this is just a test text =)');
$d->fill_element('//*[@id="attachment_name"]', 'xpath', 'Random Character');
$d->find_element('//*[@id="save"]')->click();
diag('Searching new Template');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#email_template_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', $templatename);
diag('Check Details of Template');
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[3]', $templatename), "Name is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[2]', $resellername), "Reseller is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[4]', 'default@mail.test'), "From Email is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[5]', 'Testing Stuff'), "Subject is correct");
diag('Edit Email Template');
$templatename = ("template" . int(rand(100000)) . "mail");
$d->move_and_click('//*[@id="email_template_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="email_template_table_filter"]/label/input');
$d->fill_element('//*[@id="name"]', 'xpath', $templatename);
$d->fill_element('//*[@id="from_email"]', 'xpath', 'standard@mail.test');
$d->fill_element('//*[@id="subject"]', 'xpath', 'testing much stuff');
$d->fill_element('//*[@id="body"]', 'xpath', 'No seriously, this is just for testing');
$d->fill_element('//*[@id="attachment_name"]', 'xpath', '=)');
$d->find_element('//*[@id="save"]')->click();
diag('Searching new Template');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#email_template_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', $templatename);
diag('Check Details of Template');
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[3]', $templatename), "Name is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[2]', $resellername), "Reseller is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[4]', 'standard@mail.test'), "From Email is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[5]', 'testing much stuff'), "Subject is correct");
diag('Try to NOT delete Email Template');
$d->move_and_click('//*[@id="email_template_table"]//tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="email_template_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag('Check if Template Email is still here');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#email_template_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', $templatename);
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[3]', $templatename), "Template is still here");
diag('Delete Template Email');
$d->move_and_click('//*[@id="email_template_table"]//tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="email_template_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag('Check if Template Email was deleted');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', $templatename);
ok($d->find_element_by_css('#email_template_table tr > td.dataTables_empty', 'css'), 'Template was deleted');
diag("Open delete dialog and press cancel");
$c->delete_reseller_contract($contractid, 1);
$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid);
ok($d->wait_for_text('//*[@id="contract_table"]/tbody/tr[1]/td[2]', $contractid), 'Reseller contract is still here');
diag('Open delete dialog and press delete');
$c->delete_reseller_contract($contractid, 0);
$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid);
ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty'), 'Reseller contract was deleted');
diag("Open delete dialog and press cancel");
$c->delete_reseller($resellername, 1);
$d->fill_element('//*[@id="Resellers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Resellers_table_filter"]/label/input', 'xpath', $resellername);
ok($d->wait_for_text('//*[@id="Resellers_table"]/tbody/tr[1]/td[3]', $resellername), 'Reseller is still here');
diag('Open delete dialog and press delete');
$c->delete_reseller($resellername, 0);
$d->fill_element('//*[@id="Resellers_table_filter"]/label/input', 'xpath', $resellername);
ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty'), 'Reseller was deleted');
try {
$c->login_ok();
$c->create_reseller_contract($contractid);
diag('Go to reseller page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element('Resellers', 'link_text')->click();
diag('Try to create a empty reseller');
$d->find_element('Create Reseller', 'link_text')->click();
$d->unselect_if_selected('//*[@id="contractidtable"]/tbody/tr/td[5]/input');
$d->find_element('//*[@id="save"]')->click();
diag('Check Error Messages');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Contract field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
diag('Create a legit reseller');
$d->find_element('#mod_close', 'css')->click();
$c->create_reseller($resellername, $contractid);
diag("Search our new reseller");
$d->fill_element('#Resellers_table_filter label input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#Resellers_table_filter label input', 'css', $resellername);
diag("Check Reseller Details");
ok($d->wait_for_text('//*[@id="Resellers_table"]/tbody/tr[1]/td[3]', $resellername), 'Reseller Name is correct');
ok($d->find_element_by_xpath('//*[@id="Resellers_table"]//tr//td[contains(text(), "active")]'), 'Status is correct');
diag("Click Edit on our newly created reseller");
$d->move_and_click('//*[@id="Resellers_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Resellers_table_filter"]//input');
diag("Edit name and status");
$resellername = ("reseller" . int(rand(100000)) . "test");
$d->fill_element('//*[@id="name"]', 'xpath', $resellername);
$d->find_element('//*[@id="status"]/option[@value="locked"]')->click();
$d->find_element('#save', 'css')->click();
diag("Search our new reseller");
$d->fill_element('#Resellers_table_filter label input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#Resellers_table_filter label input', 'css', $resellername);
diag("Check Reseller Details");
ok($d->wait_for_text('//*[@id="Resellers_table"]/tbody/tr[1]/td[3]', $resellername), 'Reseller Name is correct');
ok($d->find_element_by_xpath('//*[@id="Resellers_table"]//tr//td[contains(text(), "locked")]'), 'Status is correct');
diag("Click Details on our newly created reseller");
$d->move_and_click('//*[@id="Resellers_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Resellers_table_filter"]//input');
diag("Create a empty Phonebook entry");
$d->scroll_to_element($d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]'));
$d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element("Create Phonebook Entry", 'link_text'));
$d->find_element("Create Phonebook Entry", 'link_text')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Number field is required")]'));
diag("Fill in values");
$d->fill_element('//*[@id="name"]', 'xpath', 'testname');
$d->fill_element('//*[@id="number"]', 'xpath', '0123456789');
$d->find_element('//*[@id="save"]')->click();
diag("Searching Phonebook entry");
$d->scroll_to_element($d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]'));
$d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element("Create Phonebook Entry", 'link_text'));
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#phonebook_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'testname');
diag("Checking Phonebook entry details");
ok($d->wait_for_text('//*[@id="phonebook_table"]/tbody/tr/td[2]', 'testname'), 'Name is correct');
ok($d->wait_for_text('//*[@id="phonebook_table"]/tbody/tr/td[3]', '0123456789'), 'Number is correct');
diag("Edit Phonebook entry");
$d->move_and_click('//*[@id="phonebook_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="phonebook_table_filter"]/label/input');
$d->fill_element('//*[@id="name"]', 'xpath', 'newtestname');
$d->fill_element('//*[@id="number"]', 'xpath', '0987654321');
$d->find_element('//*[@id="save"]')->click();
diag("Searching Phonebook entry");
$d->scroll_to_element($d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]'));
$d->find_element('//*[@id="reseller_details"]//div//div//a[contains(text(),"Phonebook")]')->click();
$d->scroll_to_element($d->find_element("Create Phonebook Entry", 'link_text'));
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#phonebook_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="phonebook_table_filter"]/label/input', 'xpath', 'newtestname');
diag("Checking Phonebook entry details");
ok($d->wait_for_text('//*[@id="phonebook_table"]/tbody/tr/td[2]', 'newtestname'), 'Name is correct');
ok($d->wait_for_text('//*[@id="phonebook_table"]/tbody/tr/td[3]', '0987654321'), 'Number is correct');
diag('Go to Email Templates');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Email Templates", 'link_text')->click();
diag('Trying to create a empty Template');
$d->find_element("Create Email Template", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]//tr[1]/td[5]/input');
$d->find_element('//*[@id="save"]')->click();
diag('Check Error Messages');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "From Email Address field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Subject field is required")]'));
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');
$d->fill_element('//*[@id="name"]', 'xpath', $templatename);
$d->fill_element('//*[@id="from_email"]', 'xpath', 'default@mail.test');
$d->fill_element('//*[@id="subject"]', 'xpath', 'Testing Stuff');
$d->fill_element('//*[@id="body"]', 'xpath', 'Howdy Buddy, this is just a test text =)');
$d->fill_element('//*[@id="attachment_name"]', 'xpath', 'Random Character');
$d->find_element('//*[@id="save"]')->click();
diag('Searching new Template');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#email_template_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', $templatename);
diag('Check Details of Template');
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[3]', $templatename), "Name is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[2]', $resellername), "Reseller is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[4]', 'default@mail.test'), "From Email is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[5]', 'Testing Stuff'), "Subject is correct");
diag('Edit Email Template');
$templatename = ("template" . int(rand(100000)) . "mail");
$d->move_and_click('//*[@id="email_template_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="email_template_table_filter"]/label/input');
$d->fill_element('//*[@id="name"]', 'xpath', $templatename);
$d->fill_element('//*[@id="from_email"]', 'xpath', 'standard@mail.test');
$d->fill_element('//*[@id="subject"]', 'xpath', 'testing much stuff');
$d->fill_element('//*[@id="body"]', 'xpath', 'No seriously, this is just for testing');
$d->fill_element('//*[@id="attachment_name"]', 'xpath', '=)');
$d->find_element('//*[@id="save"]')->click();
diag('Searching new Template');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#email_template_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', $templatename);
diag('Check Details of Template');
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[3]', $templatename), "Name is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[2]', $resellername), "Reseller is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[4]', 'standard@mail.test'), "From Email is correct");
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[5]', 'testing much stuff'), "Subject is correct");
diag('Try to NOT delete Email Template');
$d->move_and_click('//*[@id="email_template_table"]//tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="email_template_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag('Check if Template Email is still here');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#email_template_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', $templatename);
ok($d->wait_for_text('//*[@id="email_template_table"]/tbody/tr/td[3]', $templatename), "Template is still here");
diag('Delete Template Email');
$d->move_and_click('//*[@id="email_template_table"]//tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="email_template_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag('Check if Template Email was deleted');
$d->fill_element('//*[@id="email_template_table_filter"]/label/input', 'xpath', $templatename);
ok($d->find_element_by_css('#email_template_table tr > td.dataTables_empty', 'css'), 'Template was deleted');
diag("Open delete dialog and press cancel");
$c->delete_reseller_contract($contractid, 1);
$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid);
ok($d->wait_for_text('//*[@id="contract_table"]/tbody/tr[1]/td[2]', $contractid), 'Reseller contract is still here');
diag('Open delete dialog and press delete');
$c->delete_reseller_contract($contractid, 0);
$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid);
ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty'), 'Reseller contract was deleted');
diag("Open delete dialog and press cancel");
$c->delete_reseller($resellername, 1);
$d->fill_element('//*[@id="Resellers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Resellers_table_filter"]/label/input', 'xpath', $resellername);
ok($d->wait_for_text('//*[@id="Resellers_table"]/tbody/tr[1]/td[3]', $resellername), 'Reseller is still here');
diag('Open delete dialog and press delete');
$c->delete_reseller($resellername, 0);
$d->fill_element('//*[@id="Resellers_table_filter"]/label/input', 'xpath', $resellername);
ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty'), 'Reseller was deleted');
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_rw_ruleset {
my ($port) = @_;
@ -19,169 +20,192 @@ sub ctr_rw_ruleset {
my $rulesetname = ("rule" . int(rand(100000)) . "test");
my $domainstring = ("domain" . int(rand(100000)) . ".example.org");
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
diag('Go to Rewrite Rule Sets page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element('Rewrite Rule Sets', 'link_text')->click();
diag('Trying to create a empty Rewrite Rule Set');
$d->find_element('Create Rewrite Rule Set', 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input');
$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(), "Name field is required")]'));
diag('Create a legit Rewrite Rule Set');
$d->find_element('#mod_close', 'css')->click();
$c->create_rw_ruleset($rulesetname, $resellername);
diag('Search for our new Rewrite Rule Set');
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#rewrite_rule_set_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', $rulesetname);
diag('Check Rewrite Rule Set Details');
ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]//tr[1]/td[2]', $resellername), 'Reseller Name is correct');
ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]//tr[1]/td[3]', $rulesetname), 'Ruleset Name is correct');
ok($d->find_element_by_xpath('//*[@id="rewrite_rule_set_table"]//tr[1]//td[contains(text(), "For testing purposes")]'), 'Description is correct');
diag('Edit Rewrite Rule Set');
$rulesetname = ("rule" . int(rand(100000)) . "test");
$d->move_and_click('//*[@id="rewrite_rule_set_table"]/tbody/tr[1]//td//div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="rewrite_rule_set_table_filter"]/label/input');
$d->fill_element('//*[@id="name"]', 'xpath', $rulesetname);
$d->fill_element('//*[@id="description"]', 'xpath', 'For very testing purposes');
$d->find_element('//*[@id="save"]')->click();
diag('Search for our new Rewrite Rule Set');
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#rewrite_rule_set_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', $rulesetname);
diag('Check Rewrite Rule Set Details');
ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]//tr[1]/td[2]', $resellername), 'Reseller Name is correct');
ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]//tr[1]/td[3]', $rulesetname), 'Ruleset Name is correct');
ok($d->find_element_by_xpath('//*[@id="rewrite_rule_set_table"]//tr[1]//td[contains(text(), "For very testing purposes")]'), 'Description is correct');
diag('Create a new empty Rule for Caller');
$d->move_and_click('//*[@id="rewrite_rule_set_table"]/tbody/tr[1]//td//div//a[contains(text(), "Rules")]', 'xpath', '//*[@id="rewrite_rule_set_table_filter"]/label/input');
$d->find_element('Create Rewrite Rule', 'link_text')->click;
$d->find_element('//*[@id="save"]')->click();
diag('Check Error Messages');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Match pattern field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Replacement Pattern field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Description field is required")]'));
diag('Fill in invalid info');
$d->fill_element('//*[@id="match_pattern"]', 'xpath', '^(21|\+)([4-9][0-9]+)$');
$d->fill_element('//*[@id="replace_pattern"]', 'xpath', '\4');
$d->find_element('//*[@id="save"]')->click();
diag('Check Error Messages');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Match pattern and Replace Pattern do not work together")]'));
diag('Fill in valid Values');
$d->fill_element('//*[@id="match_pattern"]', 'xpath', '^(00|\+)([1-9][0-9]+)$');
$d->fill_element('//*[@id="replace_pattern"]', 'xpath', '\2');
$d->fill_element('//*[@id="description"]', 'xpath', 'Not International to E.164');
$d->find_element('//*[@id="field"]/option[@value="caller"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if Rule has been created');
$d->find_element('Inbound Rewrite Rules for Caller', 'link_text')->click();
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "^(00|\+)([1-9][0-9]+)$")]'), "Match Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "\2")]'), "Replacement Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "Not International to E.164")]'), "Description is correct");
diag('Edit Rule for Caller');
$d->move_and_click('//*[@id="collapse_icaller"]//table//tr[1]//td//a[text()[contains(., "Edit")]]', 'xpath', '//*[@id="masthead"]//div/h2');
$d->fill_element('//*[@id="description"]', 'xpath', 'International to E.164');
$d->find_element('//*[@id="save"]')->click();
diag('Check if Rule has been edited');
$d->find_element('Inbound Rewrite Rules for Caller', 'link_text')->click();
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "^(00|\+)([1-9][0-9]+)$")]'), "Match Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "\2")]'), "Replacement Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "International to E.164")]'), "Description is correct");
diag('Create a new Rule for Callee');
$d->find_element('Create Rewrite Rule', 'link_text')->click;
$d->fill_element('//*[@id="match_pattern"]', 'xpath', '^(00|\+)([1-9][0-9]+)$');
$d->fill_element('//*[@id="replace_pattern"]', 'xpath', '\2');
$d->fill_element('//*[@id="description"]', 'xpath', 'Not International to E.164');
$d->find_element('//*[@id="field"]/option[@value="callee"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if Rule has been created');
$d->find_element('Inbound Rewrite Rules for Callee', 'link_text')->click();
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "^(00|\+)([1-9][0-9]+)$")]'), "Match Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "\2")]'), "Replacement Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "Not International to E.164")]'), "Description is correct");
diag('Edit Rule for Callee');
$d->move_and_click('//*[@id="collapse_icallee"]//table//tr[1]//td//a[text()[contains(., "Edit")]]', 'xpath', '//*[@id="masthead"]//div/h2');
$d->fill_element('//*[@id="description"]', 'xpath', 'International to E.164');
$d->find_element('//*[@id="save"]')->click();
diag('Check if Rule has been edited');
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "^(00|\+)([1-9][0-9]+)$")]'), "Match Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "\2")]'), "Replacement Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "International to E.164")]'), "Description is correct");
diag('Testing if rules can be reordered');
diag('Create a new rule for Caller');
$d->find_element('Create Rewrite Rule', 'link_text')->click;
$d->fill_element('//*[@id="match_pattern"]', 'xpath', '^(00|\+)([1-9][0-9]+)$');
$d->fill_element('//*[@id="replace_pattern"]', 'xpath', '\1');
$d->fill_element('//*[@id="description"]', 'xpath', 'International to E.164');
$d->find_element('//*[@id="field"]/option[@value="caller"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Test if new entry moves up if up arrow is clicked');
$d->find_element('Inbound Rewrite Rules for Caller', 'link_text')->click();
$d->find_element('//*[@id="collapse_icaller"]/div/table/tbody/tr/td[contains(text(), "\1")]/../td//a//i[@class="icon-arrow-up"]')->click();
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]/td[contains(text(), "\1")]'), "Replacement Pattern is correct");
diag('Trying to add the ruleset to a domain');
$c->create_domain($domainstring, $resellername);
diag('Enter Domain Preferences');
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
ok($d->wait_for_text('//*[@id="Domain_table"]/tbody/tr/td[3]', $domainstring), 'Entry was found');
$d->move_and_click('//*[@id="Domain_table"]/tbody/tr[1]//td//div//a[contains(text(),"Preferences")]', 'xpath', '//*[@id="Domain_table_filter"]/label/input');
diag('Add ruleset to a domain');
$d->find_element('Number Manipulations', 'link_text')->click();
$d->move_and_click('//table/tbody/tr/td[contains(text(), "rewrite_rule_set")]/../td/div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Number Manipulations")]');
$d->find_element('//*[@id="rewrite_rule_set.1"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if correct ruleset has been selected');
$d->find_element('Number Manipulations', 'link_text')->click;
ok($d->wait_for_text('//table/tbody/tr/td[contains(text(), "rewrite_rule_set")]/../td[4]/select/option[@selected="selected"]', $rulesetname), 'rewrite_rule_set value has been set');
diag("Open delete dialog and press cancel");
$c->delete_rw_ruleset($rulesetname, 1);
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#rewrite_rule_set_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', $rulesetname);
ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]/tbody/tr[1]/td[3]', $rulesetname), 'Ruleset is still here');
diag('Open delete dialog and press delete');
$c->delete_rw_ruleset($rulesetname, 0);
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', $rulesetname);
ok($d->find_element_by_css('#rewrite_rule_set_table tr > td.dataTables_empty', 'css'), 'Ruleset was deleted');
$c->delete_domain($domainstring);
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
try {
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
diag('Go to Rewrite Rule Sets page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element('Rewrite Rule Sets', 'link_text')->click();
diag('Trying to create a empty Rewrite Rule Set');
$d->find_element('Create Rewrite Rule Set', 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input');
$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(), "Name field is required")]'));
diag('Create a legit Rewrite Rule Set');
$d->find_element('#mod_close', 'css')->click();
$c->create_rw_ruleset($rulesetname, $resellername);
diag('Search for our new Rewrite Rule Set');
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#rewrite_rule_set_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', $rulesetname);
diag('Check Rewrite Rule Set Details');
ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]//tr[1]/td[2]', $resellername), 'Reseller Name is correct');
ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]//tr[1]/td[3]', $rulesetname), 'Ruleset Name is correct');
ok($d->find_element_by_xpath('//*[@id="rewrite_rule_set_table"]//tr[1]//td[contains(text(), "For testing purposes")]'), 'Description is correct');
diag('Edit Rewrite Rule Set');
$rulesetname = ("rule" . int(rand(100000)) . "test");
$d->move_and_click('//*[@id="rewrite_rule_set_table"]/tbody/tr[1]//td//div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="rewrite_rule_set_table_filter"]/label/input');
$d->fill_element('//*[@id="name"]', 'xpath', $rulesetname);
$d->fill_element('//*[@id="description"]', 'xpath', 'For very testing purposes');
$d->find_element('//*[@id="save"]')->click();
diag('Search for our new Rewrite Rule Set');
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#rewrite_rule_set_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', $rulesetname);
diag('Check Rewrite Rule Set Details');
ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]//tr[1]/td[2]', $resellername), 'Reseller Name is correct');
ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]//tr[1]/td[3]', $rulesetname), 'Ruleset Name is correct');
ok($d->find_element_by_xpath('//*[@id="rewrite_rule_set_table"]//tr[1]//td[contains(text(), "For very testing purposes")]'), 'Description is correct');
diag('Create a new empty Rule for Caller');
$d->move_and_click('//*[@id="rewrite_rule_set_table"]/tbody/tr[1]//td//div//a[contains(text(), "Rules")]', 'xpath', '//*[@id="rewrite_rule_set_table_filter"]/label/input');
$d->find_element('Create Rewrite Rule', 'link_text')->click;
$d->find_element('//*[@id="save"]')->click();
diag('Check Error Messages');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Match pattern field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Replacement Pattern field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Description field is required")]'));
diag('Fill in invalid info');
$d->fill_element('//*[@id="match_pattern"]', 'xpath', '^(21|\+)([4-9][0-9]+)$');
$d->fill_element('//*[@id="replace_pattern"]', 'xpath', '\4');
$d->find_element('//*[@id="save"]')->click();
diag('Check Error Messages');
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Match pattern and Replace Pattern do not work together")]'));
diag('Fill in valid Values');
$d->fill_element('//*[@id="match_pattern"]', 'xpath', '^(00|\+)([1-9][0-9]+)$');
$d->fill_element('//*[@id="replace_pattern"]', 'xpath', '\2');
$d->fill_element('//*[@id="description"]', 'xpath', 'Not International to E.164');
$d->find_element('//*[@id="field"]/option[@value="caller"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if Rule has been created');
$d->find_element('Inbound Rewrite Rules for Caller', 'link_text')->click();
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "^(00|\+)([1-9][0-9]+)$")]'), "Match Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "\2")]'), "Replacement Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "Not International to E.164")]'), "Description is correct");
diag('Edit Rule for Caller');
$d->move_and_click('//*[@id="collapse_icaller"]//table//tr[1]//td//a[text()[contains(., "Edit")]]', 'xpath', '//*[@id="masthead"]//div/h2');
$d->fill_element('//*[@id="description"]', 'xpath', 'International to E.164');
$d->find_element('//*[@id="save"]')->click();
diag('Check if Rule has been edited');
$d->find_element('Inbound Rewrite Rules for Caller', 'link_text')->click();
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "^(00|\+)([1-9][0-9]+)$")]'), "Match Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "\2")]'), "Replacement Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]//td[contains(text(), "International to E.164")]'), "Description is correct");
diag('Create a new Rule for Callee');
$d->find_element('Create Rewrite Rule', 'link_text')->click;
$d->fill_element('//*[@id="match_pattern"]', 'xpath', '^(00|\+)([1-9][0-9]+)$');
$d->fill_element('//*[@id="replace_pattern"]', 'xpath', '\2');
$d->fill_element('//*[@id="description"]', 'xpath', 'Not International to E.164');
$d->find_element('//*[@id="field"]/option[@value="callee"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if Rule has been created');
$d->find_element('Inbound Rewrite Rules for Callee', 'link_text')->click();
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "^(00|\+)([1-9][0-9]+)$")]'), "Match Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "\2")]'), "Replacement Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "Not International to E.164")]'), "Description is correct");
diag('Edit Rule for Callee');
$d->move_and_click('//*[@id="collapse_icallee"]//table//tr[1]//td//a[text()[contains(., "Edit")]]', 'xpath', '//*[@id="masthead"]//div/h2');
$d->fill_element('//*[@id="description"]', 'xpath', 'International to E.164');
$d->find_element('//*[@id="save"]')->click();
diag('Check if Rule has been edited');
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "^(00|\+)([1-9][0-9]+)$")]'), "Match Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "\2")]'), "Replacement Pattern is correct");
ok($d->find_element_by_xpath('//*[@id="collapse_icallee"]/div/table/tbody/tr[1]//td[contains(text(), "International to E.164")]'), "Description is correct");
diag('Testing if rules can be reordered');
diag('Create a new rule for Caller');
$d->find_element('Create Rewrite Rule', 'link_text')->click;
$d->fill_element('//*[@id="match_pattern"]', 'xpath', '^(00|\+)([1-9][0-9]+)$');
$d->fill_element('//*[@id="replace_pattern"]', 'xpath', '\1');
$d->fill_element('//*[@id="description"]', 'xpath', 'International to E.164');
$d->find_element('//*[@id="field"]/option[@value="caller"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Test if new entry moves up if up arrow is clicked');
$d->find_element('Inbound Rewrite Rules for Caller', 'link_text')->click();
$d->find_element('//*[@id="collapse_icaller"]/div/table/tbody/tr/td[contains(text(), "\1")]/../td//a//i[@class="icon-arrow-up"]')->click();
ok($d->find_element_by_xpath('//*[@id="collapse_icaller"]/div/table/tbody/tr[1]/td[contains(text(), "\1")]'), "Replacement Pattern is correct");
diag('Trying to add the ruleset to a domain');
$c->create_domain($domainstring, $resellername);
diag('Enter Domain Preferences');
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#Domain_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="Domain_table_filter"]/label/input', 'xpath', $domainstring);
ok($d->wait_for_text('//*[@id="Domain_table"]/tbody/tr/td[3]', $domainstring), 'Entry was found');
$d->move_and_click('//*[@id="Domain_table"]/tbody/tr[1]//td//div//a[contains(text(),"Preferences")]', 'xpath', '//*[@id="Domain_table_filter"]/label/input');
diag('Add ruleset to a domain');
$d->find_element('Number Manipulations', 'link_text')->click();
$d->move_and_click('//table/tbody/tr/td[contains(text(), "rewrite_rule_set")]/../td/div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Number Manipulations")]');
$d->find_element('//*[@id="rewrite_rule_set.1"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if correct ruleset has been selected');
$d->find_element('Number Manipulations', 'link_text')->click;
ok($d->wait_for_text('//table/tbody/tr/td[contains(text(), "rewrite_rule_set")]/../td[4]/select/option[@selected="selected"]', $rulesetname), 'rewrite_rule_set value has been set');
diag("Open delete dialog and press cancel");
$c->delete_rw_ruleset($rulesetname, 1);
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#rewrite_rule_set_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', $rulesetname);
ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]/tbody/tr[1]/td[3]', $rulesetname), 'Ruleset is still here');
diag('Open delete dialog and press delete');
$c->delete_rw_ruleset($rulesetname, 0);
$d->fill_element('//*[@id="rewrite_rule_set_table_filter"]/label/input', 'xpath', $rulesetname);
ok($d->find_element_by_css('#rewrite_rule_set_table tr > td.dataTables_empty', 'css'), 'Ruleset was deleted');
$c->delete_domain($domainstring);
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_subscriber {
my ($port) = @_;
@ -28,376 +29,398 @@ sub ctr_subscriber {
my $contractid = ("contract" . int(rand(100000)) . "test");
my $billingname = ("billing" . int(rand(100000)) . "test");
$c->login_ok();
$c->create_domain($domainstring);
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
$c->create_contact($contactmail, $resellername);
$c->create_billing_profile($billingname, $resellername);
$c->create_customer($customerid, $contactmail, $billingname);
diag("Open Details for our just created Customer");
$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist');
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', $customerid);
ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $customerid), 'Customer found');
$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Customer_table_filter"]//input');
diag("Trying to add a empty Subscriber");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]'));
$d->find_element('Create Subscriber', 'link_text')->click();
$d->unselect_if_selected('//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input');
$d->find_element('//*[@id="save"]')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Domain field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "SIP Username field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "SIP Password field is required")]'));
diag('Enter necessary information');
$d->fill_element('//*[@id="domainidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#domainidtable tr > td.dataTables_empty'), 'Table is empty');
$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');
$d->select_if_unselected('//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input');
$d->find_element('//*[@id="e164.cc"]')->send_keys('43');
$d->find_element('//*[@id="e164.ac"]')->send_keys('99');
$d->find_element('//*[@id="e164.sn"]')->send_keys(int(rand(99999999)));
$d->find_element('//*[@id="email"]')->send_keys($emailstring);
$d->find_element('//*[@id="webusername"]')->send_keys($username);
$d->find_element('//*[@id="webpassword"]')->send_keys('testing1234'); #workaround for misclicking on ok button
$d->find_element('//*[@id="gen_password"]')->click();
$d->find_element('//*[@id="username"]')->send_keys($username);
$d->find_element('//*[@id="password"]')->send_keys('testing1234'); #using normal pwd, cant easily seperate both generate buttons
$d->find_element('//*[@id="save"]')->click();
diag('Trying to find Subscriber');
$d->fill_element('//*[@id="subscribers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscribers_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscribers_table_filter"]/label/input', 'xpath', $username);
ok($d->wait_for_text('//*[@id="subscribers_table"]/tbody/tr/td[2]', $username), 'Subscriber was found');
diag('Go to Subscriber Profiles page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Subscriber Profiles", 'link_text')->click();
diag('Trying to create a empty Subscriber profile set');
$d->find_element("Create Subscriber Profile Set", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input', 'xpath');
$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(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Description field is required")]'));
diag('Enter profile set information');
$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="name"]', 'xpath', $setname);
$d->fill_element('//*[@id="description"]', 'xpath', 'This is a description. It describes things');
$d->find_element('//*[@id="save"]')->click();
diag('Trying to find Subscriber profile set');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
diag('Check details');
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[3]', $setname), 'Name is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[4]', 'This is a description. It describes things'), 'Description is correct');
ok($d->find_element_by_xpath('//*[@id="subscriber_profile_sets_table"]//tr//td[contains(text(), "' . $resellername .'")]'), 'Reseller is correct');
diag('Edit Subscriber Profile set');
$setname = ("test" . int(rand(10000)) . "set");
$d->move_and_click('//*[@id="subscriber_profile_sets_table"]/tbody/tr[1]/td/div/a[contains(text(), "Edit")]', 'xpath', '//*[@id="subscriber_profile_sets_table_filter"]/label/input');
$d->fill_element('//*[@id="name"]', 'xpath', $setname);
$d->fill_element('//*[@id="description"]', 'xpath', 'Very Good description here');
$d->find_element('//*[@id="save"]')->click();
diag('Trying to find Subscriber profile set');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
diag('Check details');
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[3]', $setname), 'Name is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[4]', 'Very Good description here'), 'Description is correct');
ok($d->find_element_by_xpath('//*[@id="subscriber_profile_sets_table"]//tr//td[contains(text(), "' . $resellername .'")]'), 'Reseller is correct');
diag('Enter "Profiles" menu');
$d->move_and_click('//*[@id="subscriber_profile_sets_table"]/tbody/tr[1]/td/div/a[contains(text(), "Profiles")]', 'xpath', '//*[@id="subscriber_profile_sets_table_filter"]/label/input');
diag('Trying to create a empty Subscriber Profile');
$d->find_element("Create Subscriber Profile", 'link_text')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Description field is required")]'));
diag('Enter profile information');
$d->fill_element('//*[@id="name"]', 'xpath', $profilename);
$d->fill_element('//*[@id="description"]', 'xpath', 'This is a description. It describes things');
$d->scroll_to_element($d->find_element('//*[@id="attribute.ncos"]'));
$d->select_if_unselected('//*[@id="attribute.ncos"]');
$d->find_element('//*[@id="save"]')->click();
diag('Search for Profile');
$d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', $profilename);
diag('Check profile details');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[3]', $profilename), 'Name is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[4]', 'This is a description. It describes things'), 'Description is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[2]', $setname), 'Profile Set is correct');
diag('Edit Subscriber Profile');
$profilename = ("test" . int(rand(10000)) . "profile");
$d->move_and_click('//*[@id="subscriber_profile_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="subscriber_profile_table_filter"]//input');
$d->fill_element('//*[@id="name"]', 'xpath', $profilename);
$d->fill_element('//*[@id="description"]', 'xpath', 'Very very useful description');
$d->find_element('//*[@id="save"]')->click();
diag('Search for Profile');
$d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', $profilename);
diag('Check profile details');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[3]', $profilename), 'Name is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[4]', 'Very very useful description'), 'Description is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[2]', $setname), 'Profile Set is correct');
diag('Go to Subscribers page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Subscribers", 'link_text')->click();
diag('Checking Subscriber Details');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username);
ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[3]', $contactmail), 'Contact Email is correct');
ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[4]', $username), 'Subscriber name is correct');
ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[5]', $domainstring), 'Domain name is correct');
diag('Go to Subscriber details');
$d->move_and_click('//*[@id="subscriber_table"]/tbody/tr[1]/td/div/a[contains(text(), "Details")]', 'xpath', '//*[@id="subscriber_table_filter"]//input');
diag('Edit master data');
$d->find_element('//*[@id="subscriber_data"]//div//a[contains(text(), "Master Data")]')->click();
$d->find_element("Edit", 'link_text')->click();
diag('Add Subscriber to profile');
$d->scroll_to_element($d->find_element('//*[@id="profile_setidtable_filter"]/label/input'));
$d->fill_element('//*[@id="profile_setidtable_filter"]/label/input', 'xpath', $setname);
ok($d->wait_for_text('//*[@id="profile_setidtable"]/tbody/tr/td[3]', $setname), 'Subscriber Profile was found');
$d->select_if_unselected('//*[@id="profile_setidtable"]/tbody/tr/td[5]');
$d->find_element('//*[@id="save"]')->click();
diag('Check if change was applied');
ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr/td[contains(text(), "Subscriber Profile Set")]/../td[contains(text(), "'. $setname .'")]'));
ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr/td[contains(text(), "Subscriber Profile")]/../td[contains(text(), "'. $profilename .'")]'));
diag('Go to Subscriber preferences');
$d->find_element("Preferences", 'link_text')->click();
diag('Trying to change subscriber IVR language');
$d->find_element("Internals", 'link_text')->click();
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "language")]'));
$d->move_and_click('//table//tr/td[contains(text(), "language")]/..//td//a[contains(text(), "Edit")]', 'xpath');
diag('Change language to German');
$d->find_element('//*[@id="language"]/option[contains(text(), "German")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if language has been applied');
$d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[contains(text(),"Internals")]'));
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "language")]/../td/select/option[contains(text(), "German") and @selected="selected"]'), '"German" has been selected');
diag('Trying to enable call recording');
$d->find_element("NAT and Media Flow Control", 'link_text')->click();
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "record_call")]'));
$d->move_and_click('//table//tr/td[contains(text(), "record_call")]/..//td//a[contains(text(), "Edit")]', 'xpath');
diag('Enable call recording');
$d->select_if_unselected('//*[@id="record_call"]');
$d->find_element('//*[@id="save"]')->click();
diag('Check if call recording was enabled');
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "record_call")]/../td//input[@checked="checked"]'), "Call recording was enabled");
diag('Trying to add a simple call forward');
$d->scroll_to_element($d->find_element("Call Forwards", 'link_text'));
$d->find_element("Call Forwards", 'link_text')->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();
diag('Add a new Source set');
$d->find_element('//*[@id="cf_actions.edit_source_sets"]')->click();
$d->find_element('Create New', 'link_text')->click();
$d->fill_element('//*[@id="name"]', 'xpath', $sourcename);
$d->fill_element('//*[@id="source.0.source"]', 'xpath', '43*');
diag('Adding another source');
$d->find_element('//*[@id="source_add"]')->click();
ok($d->fill_element('//*[@id="source.1.source"]', 'xpath', '494331337'), "New Source input was created");
$d->find_element('//*[@id="save"]')->click();
diag('Check Source set details');
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $sourcename . '")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $sourcename . '")]/../td[contains(text(), "whitelist")]'), "Mode is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $sourcename . '")]/../td[contains(text(), "43*")]'), "Number 1 is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $sourcename . '")]/../td[text()[contains(., "494331337")]]'), "Number 2 is correct");
$d->find_element('//*[@id="mod_close"]')->click();
diag('Add a new B-Number set');
$d->find_element('//*[@id="cf_actions.edit_bnumber_sets"]')->click();
$d->find_element('Create New', 'link_text')->click();
$d->fill_element('//*[@id="name"]', 'xpath', $bsetname);
$d->fill_element('//*[@id="bnumbers.0.number"]', 'xpath', '1234567890');
$d->find_element('//*[@id="save"]')->click();
diag('Check B-Number set details');
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $bsetname . '")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $bsetname . '")]/../td[contains(text(), "1234567890")]'), "Number is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $bsetname . '")]/../td[contains(text(), "whitelist")]'), "Mode is correct");
$d->find_element('//*[@id="mod_close"]')->click();
diag('Add a new Destination set');
$d->find_element('//*[@id="cf_actions.edit_destination_sets"]')->click();
$d->find_element('Create New', 'link_text')->click();
$d->fill_element('//*[@id="name"]', 'xpath', $destinationname);
$d->fill_element('//*[@id="destination.0.uri.destination"]', 'xpath', '1234567890');
$d->find_element('//*[@id="save"]')->click();
diag('Check Destination set details');
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $destinationname . '")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $destinationname . '")]/../td[contains(text(), "1234567890")]'), "Number is correct");
$d->find_element('//*[@id="mod_close"]')->click();
diag('Use new Sets');
$d->find_element('//*[@id="callforward_controls_add"]')->click();
$d->find_element('//*[@id="active_callforward.0.source_set"]/option[contains(text(), "' . $sourcename . '")]')->click();
ok($d->find_element_by_xpath('//select//option[contains(text(), "' . $sourcename . '")]')->click(), "Source set has been found");
ok($d->find_element_by_xpath('//select//option[contains(text(), "' . $destinationname . '")]')->click(), "Destination Set has been found");
ok($d->find_element_by_xpath('//select//option[contains(text(), "' . $bsetname . '")]')->click(), "B-Set has been found");
diag('Save');
$d->find_element('//*[@id="cf_actions.save"]')->click();
diag('Check if call-forward has been applied');
ok($d->find_element_by_xpath('//*[@id="preferences_table_cf"]/tbody/tr[1]/td[contains(text(), ' . $bsetname . ')]'), 'B-Set was selected');
ok($d->find_element_by_xpath('//*[@id="preferences_table_cf"]/tbody/tr[1]/td[contains(text(), ' . $destinationname . ')]'), 'Destination set was selected');
diag('Trying to add call blockings');
$d->find_element("Call Blockings", 'link_text')->click();
$d->scroll_to_element($d->find_element("Call Blockings", 'link_text'));
diag('Edit block_in_mode');
$d->move_and_click('//table//tr/td[contains(text(), "block_in_mode")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Call Blockings")]');
$d->find_element('//*[@id="block_in_mode"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if value was set');
$d->scroll_to_element($d->find_element("Call Blockings", 'link_text'));
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_mode")]/../td/input[@checked="checked"]'), "Setting is correct");
diag('Edit block_in_list');
$d->move_and_click('//table//tr/td[contains(text(), "block_in_list")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Call Blockings")]');
$d->fill_element('//*[@id="block_in_list"]', 'xpath', '1337');
$d->find_element('//*[@id="add"]')->click();
$d->fill_element('//*[@id="block_in_list"]', 'xpath', '42');
$d->find_element('//*[@id="add"]')->click();
$d->find_element('//*[@id="mod_close"]')->click();
diag('Check if value was set');
$d->scroll_to_element($d->find_element("Call Blockings", 'link_text'));
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_list")]/../td[contains(text(), "1337")]'), "Number 1 is correct");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_list")]/../td[text()[contains(., "42")]]'), "Number 2 is correct");
diag('Disable Entry');
$d->move_and_click('//table//tr/td[contains(text(), "block_in_list")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Call Blockings")]');
$d->find_element('//*[@id="mod_edit"]//div//input[@value="1337"]/../a[2]')->click();
$d->find_element('//*[@id="mod_close"]')->click();
diag('Check if Entry was disabled');
$d->scroll_to_element($d->find_element("Call Blockings", 'link_text'));
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_list")]/../td/span[@class="ngcp-entry-disabled"]/../span[contains(text(), "1337")]'), "Entry was disabled");
diag('Edit block_in_clir');
$d->move_and_click('//table//tr/td[contains(text(), "block_in_clir")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Call Blockings")]');
$d->find_element('//*[@id="block_in_clir"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if value was set');
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_clir")]/../td/input[@checked="checked"]'), "Setting is correct");
diag('Go to Subscribers Page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Subscribers", 'link_text')->click();
diag('Trying to NOT delete Subscriber');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username);
ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[4]', $username), 'Subscriber was found');
$d->move_and_click('//*[@id="subscriber_table"]/tbody/tr[1]/td/div/a[contains(text(), "Terminate")]', 'xpath', '//*[@id="subscriber_table_filter"]//input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag('Check if Subscriber is still here');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username);
ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[4]', $username), 'Subscriber is still here');
diag('Trying to delete Subscriber');
$d->move_and_click('//*[@id="subscriber_table"]/tbody/tr[1]/td/div/a[contains(text(), "Terminate")]', 'xpath', '//*[@id="subscriber_table_filter"]//input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag('Check if Subscriber has been deleted');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username);
ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty');
diag('Go to Subscriber Profiles page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Subscriber Profiles", 'link_text')->click();
diag('Trying to NOT Delete Subscriber Profile Set');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[3]', $setname), 'Profile Set was found');
$d->move_and_click('//*[@id="subscriber_profile_sets_table"]/tbody/tr[1]/td/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="subscriber_profile_sets_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag('Check if Subscriber Profile Sethas been deleted');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[3]', $setname), 'Profile Set is still here');
diag('Trying to Delete Subscriber Profile Set');
$d->move_and_click('//*[@id="subscriber_profile_sets_table"]/tbody/tr[1]/td/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="subscriber_profile_sets_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag('Check if Subscriber Profile Set has been deleted');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');
$c->delete_customer($customerid);
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
$c->delete_contact($contactmail);
$c->delete_billing_profile($billingname);
$c->delete_domain($domainstring);
try {
$c->login_ok();
$c->create_domain($domainstring);
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
$c->create_contact($contactmail, $resellername);
$c->create_billing_profile($billingname, $resellername);
$c->create_customer($customerid, $contactmail, $billingname);
diag("Open Details for our just created Customer");
$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist');
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', $customerid);
ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $customerid), 'Customer found');
$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Customer_table_filter"]//input');
diag("Trying to add a empty Subscriber");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]')->click();
$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]'));
$d->find_element('Create Subscriber', 'link_text')->click();
$d->unselect_if_selected('//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input');
$d->find_element('//*[@id="save"]')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Domain field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "SIP Username field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "SIP Password field is required")]'));
diag('Enter necessary information');
$d->fill_element('//*[@id="domainidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#domainidtable tr > td.dataTables_empty'), 'Table is empty');
$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');
$d->select_if_unselected('//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input');
$d->find_element('//*[@id="e164.cc"]')->send_keys('43');
$d->find_element('//*[@id="e164.ac"]')->send_keys('99');
$d->find_element('//*[@id="e164.sn"]')->send_keys(int(rand(99999999)));
$d->find_element('//*[@id="email"]')->send_keys($emailstring);
$d->find_element('//*[@id="webusername"]')->send_keys($username);
$d->find_element('//*[@id="webpassword"]')->send_keys('testing1234'); #workaround for misclicking on ok button
$d->find_element('//*[@id="gen_password"]')->click();
$d->find_element('//*[@id="username"]')->send_keys($username);
$d->find_element('//*[@id="password"]')->send_keys('testing1234'); #using normal pwd, cant easily seperate both generate buttons
$d->find_element('//*[@id="save"]')->click();
diag('Trying to find Subscriber');
$d->fill_element('//*[@id="subscribers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscribers_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscribers_table_filter"]/label/input', 'xpath', $username);
ok($d->wait_for_text('//*[@id="subscribers_table"]/tbody/tr/td[2]', $username), 'Subscriber was found');
diag('Go to Subscriber Profiles page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Subscriber Profiles", 'link_text')->click();
diag('Trying to create a empty Subscriber profile set');
$d->find_element("Create Subscriber Profile Set", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input', 'xpath');
$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(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Description field is required")]'));
diag('Enter profile set information');
$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="name"]', 'xpath', $setname);
$d->fill_element('//*[@id="description"]', 'xpath', 'This is a description. It describes things');
$d->find_element('//*[@id="save"]')->click();
diag('Trying to find Subscriber profile set');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
diag('Check details');
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[3]', $setname), 'Name is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[4]', 'This is a description. It describes things'), 'Description is correct');
ok($d->find_element_by_xpath('//*[@id="subscriber_profile_sets_table"]//tr//td[contains(text(), "' . $resellername .'")]'), 'Reseller is correct');
diag('Edit Subscriber Profile set');
$setname = ("test" . int(rand(10000)) . "set");
$d->move_and_click('//*[@id="subscriber_profile_sets_table"]/tbody/tr[1]/td/div/a[contains(text(), "Edit")]', 'xpath', '//*[@id="subscriber_profile_sets_table_filter"]/label/input');
$d->fill_element('//*[@id="name"]', 'xpath', $setname);
$d->fill_element('//*[@id="description"]', 'xpath', 'Very Good description here');
$d->find_element('//*[@id="save"]')->click();
diag('Trying to find Subscriber profile set');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
diag('Check details');
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[3]', $setname), 'Name is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[4]', 'Very Good description here'), 'Description is correct');
ok($d->find_element_by_xpath('//*[@id="subscriber_profile_sets_table"]//tr//td[contains(text(), "' . $resellername .'")]'), 'Reseller is correct');
diag('Enter "Profiles" menu');
$d->move_and_click('//*[@id="subscriber_profile_sets_table"]/tbody/tr[1]/td/div/a[contains(text(), "Profiles")]', 'xpath', '//*[@id="subscriber_profile_sets_table_filter"]/label/input');
diag('Trying to create a empty Subscriber Profile');
$d->find_element("Create Subscriber Profile", 'link_text')->click();
$d->find_element('//*[@id="save"]')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name field is required")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Description field is required")]'));
diag('Enter profile information');
$d->fill_element('//*[@id="name"]', 'xpath', $profilename);
$d->fill_element('//*[@id="description"]', 'xpath', 'This is a description. It describes things');
$d->scroll_to_element($d->find_element('//*[@id="attribute.ncos"]'));
$d->select_if_unselected('//*[@id="attribute.ncos"]');
$d->find_element('//*[@id="save"]')->click();
diag('Search for Profile');
$d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', $profilename);
diag('Check profile details');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[3]', $profilename), 'Name is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[4]', 'This is a description. It describes things'), 'Description is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[2]', $setname), 'Profile Set is correct');
diag('Edit Subscriber Profile');
$profilename = ("test" . int(rand(10000)) . "profile");
$d->move_and_click('//*[@id="subscriber_profile_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="subscriber_profile_table_filter"]//input');
$d->fill_element('//*[@id="name"]', 'xpath', $profilename);
$d->fill_element('//*[@id="description"]', 'xpath', 'Very very useful description');
$d->find_element('//*[@id="save"]')->click();
diag('Search for Profile');
$d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', $profilename);
diag('Check profile details');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[3]', $profilename), 'Name is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[4]', 'Very very useful description'), 'Description is correct');
ok($d->wait_for_text('//*[@id="subscriber_profile_table"]/tbody/tr/td[2]', $setname), 'Profile Set is correct');
diag('Go to Subscribers page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Subscribers", 'link_text')->click();
diag('Checking Subscriber Details');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username);
ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[3]', $contactmail), 'Contact Email is correct');
ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[4]', $username), 'Subscriber name is correct');
ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[5]', $domainstring), 'Domain name is correct');
diag('Go to Subscriber details');
$d->move_and_click('//*[@id="subscriber_table"]/tbody/tr[1]/td/div/a[contains(text(), "Details")]', 'xpath', '//*[@id="subscriber_table_filter"]//input');
diag('Edit master data');
$d->find_element('//*[@id="subscriber_data"]//div//a[contains(text(), "Master Data")]')->click();
$d->find_element("Edit", 'link_text')->click();
diag('Add Subscriber to profile');
$d->scroll_to_element($d->find_element('//*[@id="profile_setidtable_filter"]/label/input'));
$d->fill_element('//*[@id="profile_setidtable_filter"]/label/input', 'xpath', $setname);
ok($d->wait_for_text('//*[@id="profile_setidtable"]/tbody/tr/td[3]', $setname), 'Subscriber Profile was found');
$d->select_if_unselected('//*[@id="profile_setidtable"]/tbody/tr/td[5]');
$d->find_element('//*[@id="save"]')->click();
diag('Check if change was applied');
ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr/td[contains(text(), "Subscriber Profile Set")]/../td[contains(text(), "'. $setname .'")]'));
ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr/td[contains(text(), "Subscriber Profile")]/../td[contains(text(), "'. $profilename .'")]'));
diag('Go to Subscriber preferences');
$d->find_element("Preferences", 'link_text')->click();
diag('Trying to change subscriber IVR language');
$d->find_element("Internals", 'link_text')->click();
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "language")]'));
$d->move_and_click('//table//tr/td[contains(text(), "language")]/..//td//a[contains(text(), "Edit")]', 'xpath');
diag('Change language to German');
$d->find_element('//*[@id="language"]/option[contains(text(), "German")]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if language has been applied');
$d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[contains(text(),"Internals")]'));
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "language")]/../td/select/option[contains(text(), "German") and @selected="selected"]'), '"German" has been selected');
diag('Trying to enable call recording');
$d->find_element("NAT and Media Flow Control", 'link_text')->click();
$d->scroll_to_element($d->find_element('//table//tr/td[contains(text(), "record_call")]'));
$d->move_and_click('//table//tr/td[contains(text(), "record_call")]/..//td//a[contains(text(), "Edit")]', 'xpath');
diag('Enable call recording');
$d->select_if_unselected('//*[@id="record_call"]');
$d->find_element('//*[@id="save"]')->click();
diag('Check if call recording was enabled');
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "record_call")]/../td//input[@checked="checked"]'), "Call recording was enabled");
diag('Trying to add a simple call forward');
$d->scroll_to_element($d->find_element("Call Forwards", 'link_text'));
$d->find_element("Call Forwards", 'link_text')->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();
diag('Add a new Source set');
$d->find_element('//*[@id="cf_actions.edit_source_sets"]')->click();
$d->find_element('Create New', 'link_text')->click();
$d->fill_element('//*[@id="name"]', 'xpath', $sourcename);
$d->fill_element('//*[@id="source.0.source"]', 'xpath', '43*');
diag('Adding another source');
$d->find_element('//*[@id="source_add"]')->click();
ok($d->fill_element('//*[@id="source.1.source"]', 'xpath', '494331337'), "New Source input was created");
$d->find_element('//*[@id="save"]')->click();
diag('Check Source set details');
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $sourcename . '")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $sourcename . '")]/../td[contains(text(), "whitelist")]'), "Mode is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $sourcename . '")]/../td[contains(text(), "43*")]'), "Number 1 is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $sourcename . '")]/../td[text()[contains(., "494331337")]]'), "Number 2 is correct");
$d->find_element('//*[@id="mod_close"]')->click();
diag('Add a new B-Number set');
$d->find_element('//*[@id="cf_actions.edit_bnumber_sets"]')->click();
$d->find_element('Create New', 'link_text')->click();
$d->fill_element('//*[@id="name"]', 'xpath', $bsetname);
$d->fill_element('//*[@id="bnumbers.0.number"]', 'xpath', '1234567890');
$d->find_element('//*[@id="save"]')->click();
diag('Check B-Number set details');
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $bsetname . '")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $bsetname . '")]/../td[contains(text(), "1234567890")]'), "Number is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $bsetname . '")]/../td[contains(text(), "whitelist")]'), "Mode is correct");
$d->find_element('//*[@id="mod_close"]')->click();
diag('Add a new Destination set');
$d->find_element('//*[@id="cf_actions.edit_destination_sets"]')->click();
$d->find_element('Create New', 'link_text')->click();
$d->fill_element('//*[@id="name"]', 'xpath', $destinationname);
$d->fill_element('//*[@id="destination.0.uri.destination"]', 'xpath', '1234567890');
$d->find_element('//*[@id="save"]')->click();
diag('Check Destination set details');
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $destinationname . '")]'), "Name is correct");
ok($d->find_element_by_xpath('//*[@id="mod_edit"]//table//tr/td[contains(text(), "' . $destinationname . '")]/../td[contains(text(), "1234567890")]'), "Number is correct");
$d->find_element('//*[@id="mod_close"]')->click();
diag('Use new Sets');
$d->find_element('//*[@id="callforward_controls_add"]')->click();
$d->find_element('//*[@id="active_callforward.0.source_set"]/option[contains(text(), "' . $sourcename . '")]')->click();
ok($d->find_element_by_xpath('//select//option[contains(text(), "' . $sourcename . '")]')->click(), "Source set has been found");
ok($d->find_element_by_xpath('//select//option[contains(text(), "' . $destinationname . '")]')->click(), "Destination Set has been found");
ok($d->find_element_by_xpath('//select//option[contains(text(), "' . $bsetname . '")]')->click(), "B-Set has been found");
diag('Save');
$d->find_element('//*[@id="cf_actions.save"]')->click();
diag('Check if call-forward has been applied');
ok($d->find_element_by_xpath('//*[@id="preferences_table_cf"]/tbody/tr[1]/td[contains(text(), ' . $bsetname . ')]'), 'B-Set was selected');
ok($d->find_element_by_xpath('//*[@id="preferences_table_cf"]/tbody/tr[1]/td[contains(text(), ' . $destinationname . ')]'), 'Destination set was selected');
diag('Trying to add call blockings');
$d->find_element("Call Blockings", 'link_text')->click();
$d->scroll_to_element($d->find_element("Call Blockings", 'link_text'));
diag('Edit block_in_mode');
$d->move_and_click('//table//tr/td[contains(text(), "block_in_mode")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Call Blockings")]');
$d->find_element('//*[@id="block_in_mode"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if value was set');
$d->scroll_to_element($d->find_element("Call Blockings", 'link_text'));
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_mode")]/../td/input[@checked="checked"]'), "Setting is correct");
diag('Edit block_in_list');
$d->move_and_click('//table//tr/td[contains(text(), "block_in_list")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Call Blockings")]');
$d->fill_element('//*[@id="block_in_list"]', 'xpath', '1337');
$d->find_element('//*[@id="add"]')->click();
$d->fill_element('//*[@id="block_in_list"]', 'xpath', '42');
$d->find_element('//*[@id="add"]')->click();
$d->find_element('//*[@id="mod_close"]')->click();
diag('Check if value was set');
$d->scroll_to_element($d->find_element("Call Blockings", 'link_text'));
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_list")]/../td[contains(text(), "1337")]'), "Number 1 is correct");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_list")]/../td[text()[contains(., "42")]]'), "Number 2 is correct");
diag('Disable Entry');
$d->move_and_click('//table//tr/td[contains(text(), "block_in_list")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Call Blockings")]');
$d->find_element('//*[@id="mod_edit"]//div//input[@value="1337"]/../a[2]')->click();
$d->find_element('//*[@id="mod_close"]')->click();
diag('Check if Entry was disabled');
$d->scroll_to_element($d->find_element("Call Blockings", 'link_text'));
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_list")]/../td/span[@class="ngcp-entry-disabled"]/../span[contains(text(), "1337")]'), "Entry was disabled");
diag('Edit block_in_clir');
$d->move_and_click('//table//tr/td[contains(text(), "block_in_clir")]/../td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="preference_groups"]//div//a[contains(text(), "Call Blockings")]');
$d->find_element('//*[@id="block_in_clir"]')->click();
$d->find_element('//*[@id="save"]')->click();
diag('Check if value was set');
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_clir")]/../td/input[@checked="checked"]'), "Setting is correct");
diag('Go to Subscribers Page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Subscribers", 'link_text')->click();
diag('Trying to NOT delete Subscriber');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username);
ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[4]', $username), 'Subscriber was found');
$d->move_and_click('//*[@id="subscriber_table"]/tbody/tr[1]/td/div/a[contains(text(), "Terminate")]', 'xpath', '//*[@id="subscriber_table_filter"]//input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag('Check if Subscriber is still here');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username);
ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[4]', $username), 'Subscriber is still here');
diag('Trying to delete Subscriber');
$d->move_and_click('//*[@id="subscriber_table"]/tbody/tr[1]/td/div/a[contains(text(), "Terminate")]', 'xpath', '//*[@id="subscriber_table_filter"]//input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag('Check if Subscriber has been deleted');
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username);
ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty');
diag('Go to Subscriber Profiles page');
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Subscriber Profiles", 'link_text')->click();
diag('Trying to NOT Delete Subscriber Profile Set');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[3]', $setname), 'Profile Set was found');
$d->move_and_click('//*[@id="subscriber_profile_sets_table"]/tbody/tr[1]/td/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="subscriber_profile_sets_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag('Check if Subscriber Profile Sethas been deleted');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
ok($d->wait_for_text('//*[@id="subscriber_profile_sets_table"]/tbody/tr/td[3]', $setname), 'Profile Set is still here');
diag('Trying to Delete Subscriber Profile Set');
$d->move_and_click('//*[@id="subscriber_profile_sets_table"]/tbody/tr[1]/td/div/a[contains(text(), "Delete")]', 'xpath', '//*[@id="subscriber_profile_sets_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag('Check if Subscriber Profile Set has been deleted');
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');
$c->delete_customer($customerid);
$c->delete_reseller_contract($contractid);
$c->delete_reseller($resellername);
$c->delete_contact($contactmail);
$c->delete_billing_profile($billingname);
$c->delete_domain($domainstring);
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
}
if(! caller) {

@ -6,6 +6,7 @@ use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
use Selenium::Collection::Functions;
use TryCatch;
sub ctr_timeset {
my ($port) = @_;
@ -18,137 +19,160 @@ sub ctr_timeset {
my $contractid = ("contract" . int(rand(100000)) . "test");
my $timesetname = ("time" . int(rand(100000)) . "set");
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
diag("Go to Time Sets page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Time Sets", 'link_text')->click();
diag("Trying to create a empty Time Set");
$d->find_element("Create Time Set Entry", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input', 'xpath');
$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(), "Name field is required")]'));
diag("Enter Information");
$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="name"]', 'xpath', $timesetname);
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Timeset");
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#timeset_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', $timesetname);
diag("Check details");
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[3]', $timesetname), "Name is correct");
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[2]', $resellername), "Reseller is correct");
diag("Edit Timeset");
$timesetname = ("time" . int(rand(100000)) . "set");
$d->move_and_click('//*[@id="timeset_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="timeset_table_filter"]/label/input');
$d->fill_element('//*[@id="name"]', 'xpath', $timesetname);
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Timeset");
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#timeset_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', $timesetname);
diag("Check details");
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[3]', $timesetname), "Name is correct");
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[2]', $resellername), "Reseller is correct");
diag("Go to Events page");
$d->move_and_click('//*[@id="timeset_table"]//tr[1]//td//a[contains(text(), "Events")]', 'xpath', '//*[@id="timeset_table_filter"]/label/input');
diag("Trying to create a new Event");
$d->find_element("Create Event", 'link_text')->click();
diag("Fill in invalid Values");
$d->fill_element('//*[@id="comment"]', 'xpath', 'testing invalid content');
$d->fill_element('//*[@id="startdate_datetimepicker"]', 'xpath', 'invalid');
$d->fill_element('//*[@id="starttime_datetimepicker"]', 'xpath', 'stuff');
$d->find_element('//*[@id="save"]')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid datetime, must be in format yy-mm-dd HH:mm:ss")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid time, must be in format HH:mm:ss")]'));
diag("Fill in valid details");
$d->fill_element('//*[@id="comment"]', 'xpath', 'Hello, im a special Event =)');
$d->fill_element('//*[@id="startdate_datetimepicker"]', 'xpath', '2019-01-01');
$d->fill_element('//*[@id="starttime_datetimepicker"]', 'xpath', '12:00:00');
$d->find_element('//*[@id="end.switch.label.control"]')->click();
$d->fill_element('//*[@id="enddate_datetimepicker"]', 'xpath', '2019-06-05');
$d->fill_element('//*[@id="endtime_datetimepicker"]', 'xpath', '12:20:00');
$d->find_element('//*[@id="repeat.freq"]/option[@value="weekly"]')->click();
$d->find_element('//*[@id="byday.label"]')->click();
$d->select_if_unselected('//*[@id="byday.weekdays.0"]');
$d->find_element('//*[@id="save"]')->click();
diag("Search for new Event");
$d->fill_element('//*[@id="event_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#event_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="event_table_filter"]/label/input', 'xpath', 'Hello, im a special Event =)');
diag("Check Details");
ok($d->wait_for_text('//*[@id="event_table"]/tbody/tr[1]/td[2]', 'Hello, im a special Event =)'), "Description is correct");
#ok($d->find_element_by_xpath('//*[@id="event_table"]/tbody/tr[1]/td[contains(text(), "2019-01-01 12:00:00"]'), "Start Date/Time is correct");
#ok($d->find_element_by_xpath('//*[@id="event_table"]/tbody/tr[1]/td[contains(text(), "2019-06-05 12:20:00"]'), "End Date/Time is correct");
diag("Edit Event");
$d->move_and_click('//*[@id="event_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="event_table_filter"]//input');
$d->fill_element('//*[@id="comment"]', 'xpath', 'Very important event');
$d->fill_element('//*[@id="startdate_datetimepicker"]', 'xpath', '2020-06-01');
$d->fill_element('//*[@id="starttime_datetimepicker"]', 'xpath', '12:00:00');
$d->fill_element('//*[@id="enddate_datetimepicker"]', 'xpath', '2020-07-01');
$d->fill_element('//*[@id="endtime_datetimepicker"]', 'xpath', '13:00:00');
$d->find_element('//*[@id="save"]')->click();
diag("Search for Event");
$d->fill_element('//*[@id="event_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#event_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="event_table_filter"]/label/input', 'xpath', 'Very important event');
diag("Check Details");
ok($d->wait_for_text('//*[@id="event_table"]/tbody/tr[1]/td[2]', 'Very important event'), "Description is correct");
#ok($d->find_element_by_xpath('//*[@id="event_table"]/tbody/tr[1]/td[contains(text(), "2020-06-01 12:00:00"]'), "Start Date/Time is correct");
#ok($d->find_element_by_xpath('//*[@id="event_table"]/tbody/tr[1]/td[contains(text(), "2020-07-01 13:00:00"]'), "End Date/Time is correct");
diag("Go back to Time set page");
$d->find_element("Back", 'link_text')->click();
diag("Trying to NOT delete Time set");
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#timeset_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', $timesetname);
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[3]', $timesetname), "Time set was found");
$d->move_and_click('//*[@id="timeset_table"]//tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="timeset_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag("Check if Time set is still here");
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#timeset_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', $timesetname);
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[3]', $timesetname), "Time set is still here");
diag("Trying to delete Time set");
$d->move_and_click('//*[@id="timeset_table"]//tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="timeset_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if Time set was deleted");
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', $timesetname);
ok($d->find_element_by_css('#timeset_table tr > td.dataTables_empty', 'css'), 'Time set was deleted');
try {
$c->login_ok();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
diag("Go to Time Sets page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Time Sets", 'link_text')->click();
diag("Trying to create a empty Time Set");
$d->find_element("Create Time Set Entry", 'link_text')->click();
$d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input', 'xpath');
$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(), "Name field is required")]'));
diag("Enter Information");
$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="name"]', 'xpath', $timesetname);
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Timeset");
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#timeset_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', $timesetname);
diag("Check details");
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[3]', $timesetname), "Name is correct");
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[2]', $resellername), "Reseller is correct");
diag("Edit Timeset");
$timesetname = ("time" . int(rand(100000)) . "set");
$d->move_and_click('//*[@id="timeset_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="timeset_table_filter"]/label/input');
$d->fill_element('//*[@id="name"]', 'xpath', $timesetname);
$d->find_element('//*[@id="save"]')->click();
diag("Search for our new Timeset");
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#timeset_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', $timesetname);
diag("Check details");
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[3]', $timesetname), "Name is correct");
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[2]', $resellername), "Reseller is correct");
diag("Go to Events page");
$d->move_and_click('//*[@id="timeset_table"]//tr[1]//td//a[contains(text(), "Events")]', 'xpath', '//*[@id="timeset_table_filter"]/label/input');
diag("Trying to create a new Event");
$d->find_element("Create Event", 'link_text')->click();
diag("Fill in invalid Values");
$d->fill_element('//*[@id="comment"]', 'xpath', 'testing invalid content');
$d->fill_element('//*[@id="startdate_datetimepicker"]', 'xpath', 'invalid');
$d->fill_element('//*[@id="starttime_datetimepicker"]', 'xpath', 'stuff');
$d->find_element('//*[@id="save"]')->click();
diag("Check Error Messages");
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid datetime, must be in format yy-mm-dd HH:mm:ss")]'));
ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid time, must be in format HH:mm:ss")]'));
diag("Fill in valid details");
$d->fill_element('//*[@id="comment"]', 'xpath', 'Hello, im a special Event =)');
$d->fill_element('//*[@id="startdate_datetimepicker"]', 'xpath', '2019-01-01');
$d->fill_element('//*[@id="starttime_datetimepicker"]', 'xpath', '12:00:00');
$d->find_element('//*[@id="end.switch.label.control"]')->click();
$d->fill_element('//*[@id="enddate_datetimepicker"]', 'xpath', '2019-06-05');
$d->fill_element('//*[@id="endtime_datetimepicker"]', 'xpath', '12:20:00');
$d->find_element('//*[@id="repeat.freq"]/option[@value="weekly"]')->click();
$d->find_element('//*[@id="byday.label"]')->click();
$d->select_if_unselected('//*[@id="byday.weekdays.0"]');
$d->find_element('//*[@id="save"]')->click();
diag("Search for new Event");
$d->fill_element('//*[@id="event_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#event_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="event_table_filter"]/label/input', 'xpath', 'Hello, im a special Event =)');
diag("Check Details");
ok($d->wait_for_text('//*[@id="event_table"]/tbody/tr[1]/td[2]', 'Hello, im a special Event =)'), "Description is correct");
#ok($d->find_element_by_xpath('//*[@id="event_table"]/tbody/tr[1]/td[contains(text(), "2019-01-01 12:00:00"]'), "Start Date/Time is correct");
#ok($d->find_element_by_xpath('//*[@id="event_table"]/tbody/tr[1]/td[contains(text(), "2019-06-05 12:20:00"]'), "End Date/Time is correct");
diag("Edit Event");
$d->move_and_click('//*[@id="event_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="event_table_filter"]//input');
$d->fill_element('//*[@id="comment"]', 'xpath', 'Very important event');
$d->fill_element('//*[@id="startdate_datetimepicker"]', 'xpath', '2020-06-01');
$d->fill_element('//*[@id="starttime_datetimepicker"]', 'xpath', '12:00:00');
$d->fill_element('//*[@id="enddate_datetimepicker"]', 'xpath', '2020-07-01');
$d->fill_element('//*[@id="endtime_datetimepicker"]', 'xpath', '13:00:00');
$d->find_element('//*[@id="save"]')->click();
diag("Search for Event");
$d->fill_element('//*[@id="event_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#event_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="event_table_filter"]/label/input', 'xpath', 'Very important event');
diag("Check Details");
ok($d->wait_for_text('//*[@id="event_table"]/tbody/tr[1]/td[2]', 'Very important event'), "Description is correct");
#ok($d->find_element_by_xpath('//*[@id="event_table"]/tbody/tr[1]/td[contains(text(), "2020-06-01 12:00:00"]'), "Start Date/Time is correct");
#ok($d->find_element_by_xpath('//*[@id="event_table"]/tbody/tr[1]/td[contains(text(), "2020-07-01 13:00:00"]'), "End Date/Time is correct");
diag("Go back to Time set page");
$d->find_element("Back", 'link_text')->click();
diag("Trying to NOT delete Time set");
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#timeset_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', $timesetname);
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[3]', $timesetname), "Time set was found");
$d->move_and_click('//*[@id="timeset_table"]//tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="timeset_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmCancel"]')->click();
diag("Check if Time set is still here");
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($d->find_element_by_css('#timeset_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', $timesetname);
ok($d->wait_for_text('//*[@id="timeset_table"]/tbody/tr[1]/td[3]', $timesetname), "Time set is still here");
diag("Trying to delete Time set");
$d->move_and_click('//*[@id="timeset_table"]//tr[1]/td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="timeset_table_filter"]/label/input');
$d->find_element('//*[@id="dataConfirmOK"]')->click();
diag("Check if Time set was deleted");
$d->fill_element('//*[@id="timeset_table_filter"]/label/input', 'xpath', $timesetname);
ok($d->find_element_by_css('#timeset_table tr > td.dataTables_empty', 'css'), 'Time set was deleted');
} catch {
is("tests", "failed", "This test wasnt successful, check complete test logs for more info");
diag("-----------------------SCRIPT HAS CRASHED-----------------------");
if($d->find_text("Sorry!")) {
my $crashvar = $d->find_element_by_css('.error-container > h2:nth-child(2)')->get_text();
my $incident = $d->find_element_by_css('.error-details > div:nth-child(2)')->get_text();
my $time = $d->find_element_by_css('.error-details > div:nth-child(3)')->get_text();
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Server error: $crashvar");
diag($incident);
diag($time);
diag("Perl localtime(): $realtime");
} else {
diag("Could not detect Server issues. Maybe script problems?");
diag("If you still want to check server logs, here's some info");
my $realtime = localtime();
diag("Server: $ENV{CATALYST_SERVER}");
diag("Perl localtime(): $realtime");
}
diag("----------------------------------------------------------------");
}
};

Loading…
Cancel
Save