From 0a7da5812c46d2de2eff80575b9e6e1f69c51a00 Mon Sep 17 00:00:00 2001 From: Nico Schedel Date: Fri, 23 Aug 2019 11:09:26 +0200 Subject: [PATCH] TT#56376 selenium: ctr_peering: prevent missing alert from crashing script controller_peering.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: I233967e4cc9729c56dfc9cd7583249d44103d4a1 (cherry picked from commit 7699e25d788b14497dfbcc9df0dfa6b509df8dc4) --- t/selenium/controller_peering.t | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/t/selenium/controller_peering.t b/t/selenium/controller_peering.t index 826d3628c5..9732f9534a 100644 --- a/t/selenium/controller_peering.t +++ b/t/selenium/controller_peering.t @@ -54,7 +54,7 @@ $d->select_if_unselected('//table[@id="contractidtable"]/tbody/tr[1]//input[@typ $d->find_element('#save', 'css')->click(); diag("Search for the newly created Peering Group"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering group successfully created", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering group successfully created", "Correct Alert was shown"); $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); @@ -74,7 +74,7 @@ $d->find_element('//*[@id="priority"]/option[@value="1"]')->click(); $d->find_element('#save', 'css')->click(); diag("Search for the newly created Peering Group"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering group successfully updated", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering group successfully updated", "Correct Alert was shown"); $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); @@ -95,12 +95,12 @@ $d->find_element('//a[contains(text(),"Create Outbound Peering Rule")]')->click( $d->find_element('#save', 'css')->click(); diag("Check if it was created"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering rule successfully created", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering rule successfully created", "Correct Alert was shown"); 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(); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering rule successfully deleted", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering rule successfully deleted", "Correct Alert was shown"); diag("Create Outbound Peering Rule"); $d->find_element('//a[contains(text(),"Create Outbound Peering Rule")]')->click(); @@ -111,7 +111,7 @@ $d->fill_element('#description', 'css', 'for testing purposes'); $d->find_element('#save', 'css')->click(); diag("Check Outbound Peering Rule Details"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering rule successfully created", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering rule successfully created", "Correct Alert was shown"); 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"); @@ -126,7 +126,7 @@ $d->fill_element('#description', 'css', 'for very testing purposes'); $d->find_element('#save', 'css')->click(); diag("Check Outbound Peering Rule Details"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering rule successfully changed", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering rule successfully changed", "Correct Alert was shown"); 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"); @@ -147,7 +147,7 @@ $d->fill_element('//*[@id="reject_reason"]', 'xpath', 'forbidden'); $d->find_element('#save', 'css')->click(); diag("Check Inbound Peering Rule Details"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Inbound peering rule successfully created", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Inbound peering rule successfully created", "Correct Alert was shown"); 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"); @@ -161,7 +161,7 @@ $d->fill_element('//*[@id="reject_reason"]', 'xpath', 'not found'); $d->find_element('#save', 'css')->click(); diag("Check Inbound Peering Rule Details"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Inbound peering rule successfully changed", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Inbound peering rule successfully changed", "Correct Alert was shown"); 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"); @@ -183,7 +183,7 @@ ok($d->find_text('Peering server successfully created'), 'Text "Peering server s my $server_rules_uri = $d->get_current_url(); diag("Check Peering Server Details"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering server successfully created", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering server successfully created", "Correct Alert was shown"); 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"); @@ -197,7 +197,7 @@ $d->fill_element('#host', 'css', 'google.at'); $d->find_element('#save', 'css')->click(); diag("Check Peering Server Details"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering server successfully updated", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering server successfully updated", "Correct Alert was shown"); 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"); @@ -218,7 +218,7 @@ $d->find_element('#save', 'css')->click(); diag('Check if value has been applied'); $d->find_element("Number Manipulations", 'link_text')->click(); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Preference inbound_upn successfully updated", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Preference inbound_upn successfully updated", "Correct Alert was shown"); 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"'); @@ -233,7 +233,7 @@ $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'); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Preference peer_auth_user successfully updated", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Preference peer_auth_user successfully updated", "Correct Alert was shown"); $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'); @@ -244,7 +244,7 @@ $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'); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Preference peer_auth_pass successfully updated", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Preference peer_auth_pass successfully updated", "Correct Alert was shown"); $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'); @@ -255,7 +255,7 @@ $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'); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Preference peer_auth_realm successfully updated", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Preference peer_auth_realm successfully updated", "Correct Alert was shown"); $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'); @@ -268,7 +268,7 @@ ok($d->find_text("Are you sure?"), 'Delete dialog appears'); $d->find_element('#dataConfirmOK', 'css')->click(); diag("Check if Peering server was deleted"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering server successfully deleted", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering server successfully deleted", "Correct Alert was shown"); $d->fill_element('//*[@id="peering_servers_table_filter"]/label/input', 'xpath', $servername); ok($d->find_element_by_css('#peering_servers_table tr > td.dataTables_empty', 'css'), 'Peering Server was deleted'); @@ -282,7 +282,7 @@ ok($d->find_text("Are you sure?"), 'Delete dialog appears'); $d->find_element('#dataConfirmOK', 'css')->click(); diag("Check if Outbound peering rule was deleted"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering rule successfully deleted", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering rule successfully deleted", "Correct Alert was shown"); ok($d->find_element_by_css('#PeeringRules_table tr > td.dataTables_empty', 'css'), 'Outbound peering rule was deleted'); diag("Delete the Inbound Peering Rule"); @@ -295,7 +295,7 @@ ok($d->find_text("Are you sure?"), 'Delete dialog appears'); $d->find_element('#dataConfirmOK', 'css')->click(); diag("Check if Inbound peering rule was delted"); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Inbound peering rule successfully deleted", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Inbound peering rule successfully deleted", "Correct Alert was shown"); ok($d->find_element_by_css('#InboundPeeringRules_table tr > td.dataTables_empty', 'css'), 'Inbound peering rule was deleted'); diag('Go back to "SIP Peering Groups".'); @@ -320,7 +320,7 @@ ok($d->find_text("Are you sure?"), 'Delete dialog appears'); $d->find_element('#dataConfirmOK', 'css')->click(); diag('Checking if Testing Group has been deleted'); -is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering Group successfully deleted", "Correct Alert was shown"); +is($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")]')->get_text(), "Peering Group successfully deleted", "Correct Alert was shown"); $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');