TT#56376 selenium: ctr_subscriber: prevent missing alert from crashing script

controller_subscriber.t:
- sometimes, alerts wont get displayed in this test, which causes the script
to crash completley. it will now print a error message instead of crashing
the entire test

Change-Id: I3e8d1e98e38b2545839f127307f2a3696fefc59c
(cherry picked from commit 94d034e239)
changes/69/32669/2
Nico Schedel 6 years ago
parent 882849f26b
commit 70f55facd1

@ -73,7 +73,7 @@ $d->find_element('//*[@id="password"]')->send_keys('testing1234'); #using normal
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Trying to find Subscriber'); diag('Trying to find Subscriber');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Subscriber successfully created", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Subscriber successfully created", "Correct Alert was shown");
$d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]')->click(); $d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]')->click();
$d->fill_element('//*[@id="subscribers_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); $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'); ok($d->find_element_by_css('#subscribers_table tr > td.dataTables_empty'), 'Table is empty');
@ -105,7 +105,7 @@ $d->fill_element('//*[@id="description"]', 'xpath', 'This is a description. It d
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Trying to find Subscriber profile set'); diag('Trying to find Subscriber profile set');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Subscriber profile set successfully created", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Subscriber profile set successfully created", "Correct Alert was shown");
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); $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'); 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); $d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
@ -123,7 +123,7 @@ $d->fill_element('//*[@id="description"]', 'xpath', 'Very Good description here'
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Trying to find Subscriber profile set'); diag('Trying to find Subscriber profile set');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Subscriber profile set successfully updated", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Subscriber profile set successfully updated", "Correct Alert was shown");
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); $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'); 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); $d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname);
@ -152,7 +152,7 @@ $d->select_if_unselected('//*[@id="attribute.ncos"]');
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Search for Profile'); diag('Search for Profile');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Subscriber profile successfully created", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Subscriber profile successfully created", "Correct Alert was shown");
$d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); $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'); 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); $d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', $profilename);
@ -170,7 +170,7 @@ $d->fill_element('//*[@id="description"]', 'xpath', 'Very very useful descriptio
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Search for Profile'); diag('Search for Profile');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Subscriber profile successfully updated", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Subscriber profile successfully updated", "Correct Alert was shown");
$d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); $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'); 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); $d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpath', $profilename);
@ -208,7 +208,7 @@ $d->select_if_unselected('//*[@id="profile_setidtable"]/tbody/tr/td[5]');
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Check if change was applied'); diag('Check if change was applied');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Successfully updated subscriber", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Successfully updated subscriber", "Correct Alert was shown");
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 Set")]/../td[contains(text(), "'. $setname .'")]'));
ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr/td[contains(text(), "Subscriber Profile")]/../td[contains(text(), "'. $profilename .'")]')); ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr/td[contains(text(), "Subscriber Profile")]/../td[contains(text(), "'. $profilename .'")]'));
@ -220,7 +220,7 @@ $d->find_element('//*[@id="status"]/option[contains(text(), "locked")]')->click(
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Check if subscriber got locked'); diag('Check if subscriber got locked');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Successfully updated subscriber", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Successfully updated subscriber", "Correct Alert was shown");
#ok($d->find_element_by_xpath('//div[text()[contains(., "Subscriber status is locked")]]'), 'Message "Subscriber status is locked" was shown'); #ok($d->find_element_by_xpath('//div[text()[contains(., "Subscriber status is locked")]]'), 'Message "Subscriber status is locked" was shown');
#ok($d->find_element_by_xpath('//div[text()[contains(., "Subscriber is locked for global")]]'), 'Message "Subscriber is locked for global" was shown'); #ok($d->find_element_by_xpath('//div[text()[contains(., "Subscriber is locked for global")]]'), 'Message "Subscriber is locked for global" was shown');
ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr//td[contains(text(), "Status")]/../td[contains(text(), "locked")]'), "Status is correct"); ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr//td[contains(text(), "Status")]/../td[contains(text(), "locked")]'), "Status is correct");
@ -234,7 +234,7 @@ $d->find_element('//*[@id="status"]/option[contains(text(), "active")]')->click(
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Check if subscriber got unlocked'); diag('Check if subscriber got unlocked');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Successfully updated subscriber", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Successfully updated subscriber", "Correct Alert was shown");
ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr//td[contains(text(), "Status")]/../td[contains(text(), "active")]'), "Status is correct"); ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr//td[contains(text(), "Status")]/../td[contains(text(), "active")]'), "Status is correct");
diag('Go to Subscriber preferences'); diag('Go to Subscriber preferences');
@ -251,7 +251,7 @@ $d->find_element('//*[@id="language"]/option[contains(text(), "German")]')->clic
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Check if language has been applied'); diag('Check if language has been applied');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Preference language successfully updated", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Preference language successfully updated", "Correct Alert was shown");
$d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[contains(text(),"Internals")]')); $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'); 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');
@ -266,7 +266,7 @@ $d->select_if_unselected('//*[@id="record_call"]');
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Check if call recording was enabled'); diag('Check if call recording was enabled');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Preference record_call successfully updated", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Preference record_call successfully updated", "Correct Alert was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "record_call")]/../td//input[@checked="checked"]'), "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'); diag('Trying to add a simple call forward');
@ -330,7 +330,7 @@ diag('Save');
$d->find_element('//*[@id="cf_actions.save"]')->click(); $d->find_element('//*[@id="cf_actions.save"]')->click();
diag('Check if call-forward has been applied'); diag('Check if call-forward has been applied');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Successfully saved Call Forward", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Successfully saved Call Forward", "Correct Alert was shown");
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(), ' . $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'); ok($d->find_element_by_xpath('//*[@id="preferences_table_cf"]/tbody/tr[1]/td[contains(text(), ' . $destinationname . ')]'), 'Destination set was selected');
@ -345,7 +345,7 @@ $d->find_element('//*[@id="save"]')->click();
diag('Check if value was set'); diag('Check if value was set');
$d->scroll_to_element($d->find_element("Call Blockings", 'link_text')); $d->scroll_to_element($d->find_element("Call Blockings", 'link_text'));
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Preference block_in_mode successfully updated", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Preference block_in_mode successfully updated", "Correct Alert was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_mode")]/../td/input[@checked="checked"]'), "Setting is correct"); 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'); diag('Edit block_in_list');
@ -376,7 +376,7 @@ $d->find_element('//*[@id="block_in_clir"]')->click();
$d->find_element('//*[@id="save"]')->click(); $d->find_element('//*[@id="save"]')->click();
diag('Check if value was set'); diag('Check if value was set');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Preference block_in_clir successfully updated", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Preference block_in_clir successfully updated", "Correct Alert was shown");
ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "block_in_clir")]/../td/input[@checked="checked"]'), "Setting is correct"); 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'); diag('Go to Subscribers Page');
@ -402,7 +402,7 @@ $d->move_and_click('//*[@id="subscriber_table"]/tbody/tr[1]/td/div/a[contains(te
$d->find_element('//*[@id="dataConfirmOK"]')->click(); $d->find_element('//*[@id="dataConfirmOK"]')->click();
diag('Check if Subscriber has been deleted'); diag('Check if Subscriber has been deleted');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Successfully terminated subscriber", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Successfully terminated subscriber", "Correct Alert was shown");
$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username); $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'); ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty');
$d->find_element('//*[@id="content"]//div//a[contains(text(), "Back")]')->click(); $d->find_element('//*[@id="content"]//div//a[contains(text(), "Back")]')->click();
@ -430,7 +430,7 @@ $d->move_and_click('//*[@id="subscriber_profile_sets_table"]/tbody/tr[1]/td/div/
$d->find_element('//*[@id="dataConfirmOK"]')->click(); $d->find_element('//*[@id="dataConfirmOK"]')->click();
diag('Check if Subscriber Profile Set has been deleted'); diag('Check if Subscriber Profile Set has been deleted');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Subscriber profile set successfully deleted", "Correct Alert was shown"); is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Subscriber profile set successfully deleted", "Correct Alert was shown");
$d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname); $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'); ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty');

Loading…
Cancel
Save