From 53b958f224c3584fcd285da4c6896319f091cb98 Mon Sep 17 00:00:00 2001 From: Nico Schedel Date: Tue, 30 Jul 2019 12:06:11 +0200 Subject: [PATCH] TT#63700 update selenium tests to work with new docker image noteable changes: - added function wait_for_attribute, which will pause the script until a elements attribute changes to a desired value - move_action is no longer available, was replaced with ActionChains - fill_element now scrolls to element when it needs to. removed unnecessary scroll_to_element lines with it - there are now checks if a edit window is opened, to prevent element_not_interactable exception - some checks needed sleep(1), else the test would be redirected to a totaly wrong page - added some checks to see if test is on the right page, to prevent failing alert checks Change-Id: Ic516fbd1c5bc94bd8b7cb21b1d6bd089d8880fdf --- .../Remote/Driver/FirefoxExtensions.pm | 29 +++++++++++++++---- t/selenium/controller_billing.t | 6 +--- t/selenium/controller_customer.t | 18 +++++++++--- t/selenium/controller_domain.t | 10 +++++++ t/selenium/controller_emergency.t | 4 +-- t/selenium/controller_invoice.t | 1 - t/selenium/controller_ncos.t | 4 +++ t/selenium/controller_other.t | 5 +++- t/selenium/controller_peering.t | 22 +++++++------- t/selenium/controller_reseller.t | 3 +- t/selenium/controller_rw_ruleset.t | 7 ++++- t/selenium/controller_subscriber.t | 4 ++- t/selenium/controller_timeset.t | 4 +-- 13 files changed, 82 insertions(+), 35 deletions(-) diff --git a/t/lib/Selenium/Remote/Driver/FirefoxExtensions.pm b/t/lib/Selenium/Remote/Driver/FirefoxExtensions.pm index 28ccbfb26b..615f10c1cd 100644 --- a/t/lib/Selenium/Remote/Driver/FirefoxExtensions.pm +++ b/t/lib/Selenium/Remote/Driver/FirefoxExtensions.pm @@ -5,6 +5,7 @@ use strict; use TryCatch; use Moo; use Selenium::Remote::WDKeys; +use Selenium::ActionChains; use Test::More import => [qw(diag ok is)]; extends 'Selenium::Firefox'; @@ -72,6 +73,7 @@ sub unselect_if_selected { sub fill_element { my ($self, $query, $scheme, $filltext) = @_; my $elem = $self->find_element($query, $scheme); + $self->scroll_to_element($elem); return 0 unless $elem; return 0 unless $elem->is_displayed; $elem->send_keys(KEYS->{'control'}, 'A'); @@ -118,12 +120,13 @@ sub wait_for_text { return 1 if $self->find_element($xpath)->get_text() eq $expected; }; } - return; + return 0; } sub move_and_click { my ($self, $path, $type, $fallback, $timeout) = @_; return unless $path && $type; + my $action_chains = Selenium::ActionChains->new(driver => $self); $timeout = 15 unless $timeout; # seconds. Default timeout value if none is specified. my $started = time(); my $elapsed = time(); @@ -131,13 +134,29 @@ sub move_and_click { $elapsed = time(); try{ if($fallback) { - $self->move_action(element => $self->find_element($fallback, $type)); + $action_chains->move_to_element($self->find_element($fallback, $type)); } - $self->move_action(element => $self->find_element($path, $type)); - $self->find_element($path, $type)->click(); + $action_chains->move_to_element($self->find_element($path, $type)); + $action_chains->click($self->find_element($path, $type)); + $action_chains->perform; return 1; }; } - return; + return 0; +} + +sub wait_for_attribute { + my ($self, $path, $attrib, $expected, $timeout) = @_; + return unless $path && $attrib && $expected; + $timeout = 15 unless $timeout; # seconds. Default timeout value if none is specified. + my $started = time(); + my $elapsed = time(); + while ($elapsed - $started <= $timeout){ + $elapsed = time(); + try{ + return 1 if $self->find_element($path)->get_attribute($attrib, 1) eq $expected; + }; + } + return 0; } 1; diff --git a/t/selenium/controller_billing.t b/t/selenium/controller_billing.t index a63b32eb3d..8b5bfb668e 100644 --- a/t/selenium/controller_billing.t +++ b/t/selenium/controller_billing.t @@ -107,7 +107,6 @@ ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Destination fi diag('Fill in invalid values'); $d->fill_element('#source', 'css', '.*'); $d->fill_element('#destination', 'css', '.+'); -$d->scroll_to_element($d->find_element('//*[@id="onpeak_init_rate"]')); $d->fill_element('//*[@id="onpeak_init_rate"]', 'xpath', 'e'); $d->fill_element('//*[@id="onpeak_init_interval"]', 'xpath', 'e'); $d->fill_element('//*[@id="onpeak_follow_rate"]', 'xpath', 'e'); @@ -121,7 +120,6 @@ ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Onpeak init in ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Onpeak follow interval must be greater than 0")]')); diag('Fill in more invalid Values'); -$d->scroll_to_element($d->find_element('//*[@id="onpeak_init_rate"]')); $d->fill_element('//*[@id="onpeak_init_rate"]', 'xpath', '0'); $d->fill_element('//*[@id="onpeak_init_interval"]', 'xpath', '-10'); $d->fill_element('//*[@id="onpeak_follow_rate"]', 'xpath', '0'); @@ -218,7 +216,7 @@ ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billing $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")]'); +$d->move_and_click('//table//td[contains(text(),"Wednesday")]/..//a[text()[contains(.,"Edit")]]', 'xpath', '//table//td[contains(text(),"Monday")]'); ok($d->find_text("Edit Wednesday"), 'Edit dialog was opened'); diag("Fill in invalid values"); @@ -271,7 +269,6 @@ $d->find_element('#save', 'css')->click(); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), 'Special offpeak entry successfully created', "Correct Alert 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'); @@ -285,7 +282,6 @@ $d->fill_element('#end', 'css', "2019-01-01 23:59:59"); $d->find_element('#save', 'css')->click(); 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', '2018-01-01 00:00:00'); diff --git a/t/selenium/controller_customer.t b/t/selenium/controller_customer.t index 4fa0e4e266..c5fc7632a0 100644 --- a/t/selenium/controller_customer.t +++ b/t/selenium/controller_customer.t @@ -78,6 +78,7 @@ is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), $compstri diag("Check if Customer is locked"); $d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Customer_table_filter"]//input'); +$d->find_element_by_xpath('//div/h2[contains(text(), "Customer Details")]'); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), 'Customer is locked', "Correct Alert was shown"); diag("Go back and edit Customer"); @@ -121,11 +122,12 @@ $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->fill_element('#countryidtable_filter input', 'css', 'Ukraine'); $d->select_if_unselected('//table[@id="countryidtable"]/tbody/tr[1]/td[contains(text(),"Ukraine")]/..//input[@type="checkbox"]'); -$d->find_element('#save', 'css')->click(); # Save +$d->find_element('#save', 'css')->click(); diag("Check contact details"); +$d->find_element('//div[contains(@class,"accordion-heading")]//a[contains(text(),"Contact Details")]')->click(); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), 'Contact successfully changed', "Correct Alert 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"); @@ -135,6 +137,7 @@ ok($d->find_element_by_xpath('//*[@id="collapse_contact"]//table//tr//td[contain 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('//div[contains(@class,"accordion-heading")]//a[contains(text(),"Contact Details")]')->click(); $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")]'); @@ -155,10 +158,17 @@ $d->find_element('#save', 'css')->click(); diag("Check Fraud Limit details"); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), 'Fraud settings successfully changed!', "Correct Alert was shown"); +$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Fraud Limits")]')); +if($d->find_element('//*[@id="collapse_fraud"]')->get_attribute('class', 1) eq 'accordion-body collapse') { + $d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Fraud Limits")]')->click(); +} 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(),"Fraud Limits")]')->click(); +$d->find_element('//*[@id="customer_details"]//div//a[contains(text(),"Fraud Limits")]')->click(); +$d->wait_for_attribute('//*[@id="customer_details"]//div//a[contains(text(),"Fraud Limits")]', 'class', 'accordion-toggle collapsed'); $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")]')); @@ -178,7 +188,6 @@ $d->find_element('//*[@id="save"]')->click(); diag("Search for Phonebook Entry"); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), 'Phonebook entry successfully created', "Correct Alert was shown"); $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'); @@ -198,7 +207,6 @@ $d->find_element('//*[@id="save"]')->click(); diag("Check if information has changed"); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), 'Phonebook entry successfully updated', "Correct Alert was shown"); $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'); @@ -206,6 +214,8 @@ ok($d->find_element_by_xpath('//*[@id="phonebook_table"]/tbody/tr[1]/td[contains 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(),"Phonebook")]')->click(); +$d->wait_for_attribute('//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]', 'class', 'accordion-toggle collapsed'); $d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Locations")]')->click(); $d->find_element("Create Location", 'link_text')->click(); diff --git a/t/selenium/controller_domain.t b/t/selenium/controller_domain.t index 2ed5b7bb6e..ed4ce61bfb 100644 --- a/t/selenium/controller_domain.t +++ b/t/selenium/controller_domain.t @@ -47,6 +47,7 @@ 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"); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->fill_element('#concurrent_max', 'css', 'thisisnonumber'); $d->find_element("#save", 'css')->click(); @@ -58,11 +59,13 @@ $d->fill_element('#concurrent_max', 'css', '789'); $d->find_element('#save', 'css')->click(); diag('Check if value has been applied'); +$d->find_element("Access Restrictions", 'link_text')->click(); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Preference concurrent_max successfully updated", "Correct Alert 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); diag("Enter an IP address"); $d->find_element('//*[@id="add"]')->click(); @@ -82,6 +85,7 @@ ok($d->find_element_by_xpath('//table/tbody/tr/td[contains(text(), "allowed_ips" 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->fill_element('//*[@id="allowed_ips"]', 'xpath', '10.0.0.138'); $d->find_element('//*[@id="add"]')->click(); $d->find_element('//*[@id="mod_close"]')->click(); @@ -91,6 +95,7 @@ ok($d->find_element_by_xpath('//table/tbody/tr/td[contains(text(), "allowed_ips" 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->find_element('//*[@id="mod_edit"]/div[2]/div[2]/a')->click(); $d->find_element('//*[@id="mod_close"]')->click(); @@ -98,12 +103,14 @@ 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->find_element("Access Restrictions", 'link_text')->click(); $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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->select_if_unselected('//*[@id="transcode_opus_mono"]'); $d->find_element('//*[@id="save"]')->click(); @@ -114,6 +121,7 @@ ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "transcode_opus_mo 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); diag("Change to 32 kbit/s"); $d->find_element('//*[@id="opus_mono_bitrate"]/option[contains(text(), "32")]')->click(); @@ -126,6 +134,7 @@ ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "opus_mono_bitrate 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->select_if_unselected('//*[@id="transcode_opus_stereo"]'); $d->find_element('//*[@id="save"]')->click(); @@ -136,6 +145,7 @@ ok($d->find_element_by_xpath('//table//tr/td[contains(text(), "transcode_opus_st 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); diag("Change to 32 kbit/s"); $d->find_element('//*[@id="opus_stereo_bitrate"]/option[contains(text(), "32")]')->click(); diff --git a/t/selenium/controller_emergency.t b/t/selenium/controller_emergency.t index 052717591e..fdb4295600 100644 --- a/t/selenium/controller_emergency.t +++ b/t/selenium/controller_emergency.t @@ -91,7 +91,6 @@ $d->fill_element('//*[@id="prefix"]', 'xpath', "E1_133_"); $d->find_element('//*[@id="save"]')->click(); diag("Search for our new Emergency Mapping"); -$d->scroll_to_element($d->find_element('//*[@id="emergency_mappings_table_filter"]//input')); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Emergency mapping successfully created", "Correct Alert was shown"); $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'); @@ -138,6 +137,7 @@ $d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[con 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->find_element('//*[@id="emergency_mapping_container"]/option[contains(text(), "' . $containername . '")]')->click(); $d->find_element('//*[@id="save"]')->click(); @@ -152,6 +152,7 @@ $d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[con 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->select_if_unselected('//*[@id="emergency_mode_enabled"]'); $d->find_element('//*[@id="save"]')->click(); @@ -164,7 +165,6 @@ $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->scroll_to_element($d->find_element('//*[@id="emergency_mappings_table_filter"]//input')); $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); diff --git a/t/selenium/controller_invoice.t b/t/selenium/controller_invoice.t index 05a090af7e..3fd2576473 100644 --- a/t/selenium/controller_invoice.t +++ b/t/selenium/controller_invoice.t @@ -108,7 +108,6 @@ ok($d->find_element_by_css('#templateidtable tr > td.dataTables_empty', 'css'), $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); diff --git a/t/selenium/controller_ncos.t b/t/selenium/controller_ncos.t index 66624f7763..3676b7fb4a 100644 --- a/t/selenium/controller_ncos.t +++ b/t/selenium/controller_ncos.t @@ -129,6 +129,8 @@ ok($d->find_element_by_xpath('//*[@id="ncos_level_table"]/tbody/tr[1]/td[contain 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'); +ok($d->find_element_by_xpath('//*[@id="masthead"]//div//h2[contains(text(), "NCOS details")]'), "We are on the correct Page"); +sleep 1; diag("Create new pattern"); $d->find_element("Create Pattern Entry", 'link_text')->click(); @@ -140,6 +142,7 @@ diag("Check Error messages"); ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Pattern field is required")]')); diag("Enter pattern details"); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Create Number Pattern")]'), "Edit Window has been opened"); $d->fill_element('//*[@id="pattern"]', 'xpath', '^439'); $d->fill_element('//*[@id="description"]', 'xpath', 'Austrian Premium Numbers'); $d->find_element('//*[@id="save"]')->click(); @@ -212,6 +215,7 @@ $d->scroll_to_element($d->find_element('//*[@id="preference_groups"]//div//a[con 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->find_element('//*[@id="ncos"]/option[contains(text(), "' . $ncosname . '")]')->click(); $d->find_element('//*[@id="save"]')->click(); diff --git a/t/selenium/controller_other.t b/t/selenium/controller_other.t index 1f0cbab0bc..7e9ac76952 100644 --- a/t/selenium/controller_other.t +++ b/t/selenium/controller_other.t @@ -59,6 +59,7 @@ ok($d->find_element_by_xpath('//*[@id="call_list_suppression_table"]//tr[1]/td[c diag('Edit Call list suppression'); $d->move_and_click('//*[@id="call_list_suppression_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="call_list_suppression_table_filter"]//input'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Call List Suppression")]'), "Edit Window has been opened"); $d->find_element('//*[@id="direction"]/option[@value="incoming"]')->click(); $d->fill_element('//*[@id="pattern"]', 'xpath', 'testing'); $d->find_element('//*[@id="mode"]/option[@value="obfuscate"]')->click(); @@ -135,6 +136,7 @@ ok($d->find_element_by_xpath('//*[@id="phonebook_table"]//tr[1]/td[contains(text diag('Edit Phonebook entry'); $phonebookname = ("phone" . int(rand(100000)) . "book"); $d->move_and_click('//*[@id="phonebook_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="phonebook_table_filter"]//input'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Phonebook")]'), "Edit Window has been opened"); $d->fill_element('//*[@id="name"]', 'xpath', $phonebookname); $d->fill_element('//*[@id="number"]', 'xpath', '9876543210'); $d->find_element('//*[@id="save"]')->click(); @@ -210,6 +212,7 @@ ok($d->find_element_by_xpath('//*[@id="contact_table"]//tr[1]/td[contains(text() diag('Edit Contact'); $contactmail = ("contact" . int(rand(100000)) . '@test.org'); $d->move_and_click('//*[@id="contact_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="contact_table_filter"]//input'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Contact")]'), "Edit Window has been opened"); $d->fill_element('//*[@id="firstname"]', 'xpath', 'Tester'); $d->fill_element('//*[@id="lastname"]', 'xpath', 'Using'); $d->fill_element('//*[@id="company"]', 'xpath', 'sip'); @@ -265,7 +268,7 @@ $run_ok = 1; END { if(!$run_ok) { - $c->crash_handler("/results/crash_header.png"); + $c->crash_handler("/results/crash_other.png"); } $d->quit(); done_testing; diff --git a/t/selenium/controller_peering.t b/t/selenium/controller_peering.t index 5f0c250a21..0279d57469 100644 --- a/t/selenium/controller_peering.t +++ b/t/selenium/controller_peering.t @@ -47,8 +47,8 @@ $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->fill_element('//*[@id="name"]', 'xpath', $groupname); +$d->fill_element('//*[@id="description"]', 'xpath', '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(); @@ -87,6 +87,8 @@ ok($d->wait_for_text('//*[@id="sip_peering_group_table"]/tbody/tr/td[5]', 'A gro 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', '//*[@id="sip_peering_group_table_filter"]//input'); +ok($d->find_element_by_xpath('//*[@id="masthead"]//div//h2[contains(text(), "SIP Peering Group")]'), "We are on the correct Page"); +sleep 1; diag("Create empty Outbound Peering Rule"); $d->find_element('//a[contains(text(),"Create Outbound Peering Rule")]')->click(); @@ -201,10 +203,6 @@ ok($d->find_element_by_xpath('//*[@id="peering_servers_table"]/tbody/tr/td[conta 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"'); @@ -212,21 +210,25 @@ $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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); 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'); +$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"); 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->find_element("Number Manipulations", 'link_text')->click(); $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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->fill_element('//*[@id="peer_auth_user"]', 'xpath', 'peeruser1'); $d->find_element('#save', 'css')->click(); @@ -237,6 +239,7 @@ ok($d->wait_for_text('//table/tbody/tr/td[contains(text(), "peer_auth_user")]/.. 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->fill_element('//*[@id="peer_auth_pass"]', 'xpath', 'peerpass1'); $d->find_element('#save', 'css')->click(); @@ -247,6 +250,7 @@ ok($d->wait_for_text('//table/tbody/tr/td[contains(text(), "peer_auth_pass")]/.. 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->fill_element('//*[@id="peer_auth_realm"]', 'xpath', 'testpeering.com'); $d->find_element('#save', 'css')->click(); @@ -259,16 +263,13 @@ 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(); 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"); +$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'); diag("Delete the Outbound Peering Rule"); @@ -285,7 +286,6 @@ is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Peering ok($d->find_element_by_css('#PeeringRules_table tr > td.dataTables_empty', 'css'), 'Outbound peering rule was deleted'); 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'); diff --git a/t/selenium/controller_reseller.t b/t/selenium/controller_reseller.t index 79c239777f..03b86fce6c 100644 --- a/t/selenium/controller_reseller.t +++ b/t/selenium/controller_reseller.t @@ -69,6 +69,7 @@ ok($d->find_element_by_xpath('//*[@id="Resellers_table"]//tr//td[contains(text() diag("Go to Details and check if 'Reseller is locked' message appears"); $d->move_and_click('//*[@id="Resellers_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Resellers_table_filter"]//input'); +ok($d->find_element_by_xpath('//*[@id="masthead"]//div//h2[contains(text(), "Reseller Details")]'), "We are on the correct Page"); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Reseller is locked", "'Reseller is locked' message appears"); $d->find_element("Back", 'link_text')->click(); @@ -113,7 +114,6 @@ diag("Searching Phonebook entry"); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Phonebook entry successfully created", "Correct Alert was shown"); $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'); @@ -132,7 +132,6 @@ diag("Searching Phonebook entry"); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Phonebook entry successfully updated", "Correct Alert was shown"); $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'); diff --git a/t/selenium/controller_rw_ruleset.t b/t/selenium/controller_rw_ruleset.t index 2d1241e0d0..1389065a3a 100644 --- a/t/selenium/controller_rw_ruleset.t +++ b/t/selenium/controller_rw_ruleset.t @@ -69,8 +69,12 @@ ok($d->wait_for_text('//*[@id="rewrite_rule_set_table"]//tr[1]/td[2]', $reseller 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'); +diag('Go To Rewrite Rule Set Rules'); $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'); +ok($d->find_element_by_xpath('//*[@id="masthead"]//div//h2[contains(text(), "Rewrite Rules")]'), "We are on the correct Page"); +sleep 1; + +diag('Create a new empty Rule for Caller'); $d->find_element('Create Rewrite Rule', 'link_text')->click; $d->find_element('//*[@id="save"]')->click(); @@ -211,6 +215,7 @@ $d->move_and_click('//*[@id="Domain_table"]/tbody/tr[1]//td//div//a[contains(tex 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")]'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Preference")]'), "Edit Window has been opened"); $d->find_element('//*[@id="rewrite_rule_set"]/option[contains(text(), "' . $rulesetname . '")]')->click(); $d->find_element('//*[@id="save"]')->click(); diff --git a/t/selenium/controller_subscriber.t b/t/selenium/controller_subscriber.t index 43f3529cba..f9abef9536 100644 --- a/t/selenium/controller_subscriber.t +++ b/t/selenium/controller_subscriber.t @@ -74,6 +74,7 @@ $d->find_element('//*[@id="save"]')->click(); diag('Trying to find Subscriber'); is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), "Subscriber successfully created", "Correct Alert was shown"); +$d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]')->click(); $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); @@ -199,7 +200,6 @@ $d->find_element('//*[@id="subscriber_data"]//div//a[contains(text(), "Master Da $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', 'thisshouldnotexist'); ok($d->find_element_by_css('#profile_setidtable tr > td.dataTables_empty'), 'Garbage Text was not found'); $d->fill_element('//*[@id="profile_setidtable_filter"]/label/input', 'xpath', $setname); @@ -213,6 +213,7 @@ ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr/td[contains(text( ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr/td[contains(text(), "Subscriber Profile")]/../td[contains(text(), "'. $profilename .'")]')); diag('Lock Subscriber'); +$d->find_element('//*[@id="subscriber_data"]//div//a[contains(text(), "Master Data")]')->click(); $d->find_element("Edit", 'link_text')->click(); $d->find_element('//*[@id="lock"]/option[contains(text(), "global")]')->click(); $d->find_element('//*[@id="status"]/option[contains(text(), "locked")]')->click(); @@ -226,6 +227,7 @@ ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr//td[contains(text ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr//td[contains(text(), "Status")]/../td[contains(text(), "locked")]'), "Status is correct"); diag('Unlock Subscriber'); +$d->find_element('//*[@id="subscriber_data"]//div//a[contains(text(), "Master Data")]')->click(); $d->find_element("Edit", 'link_text')->click(); $d->find_element('//*[@id="lock"]/option[contains(text(), "none")]')->click(); $d->find_element('//*[@id="status"]/option[contains(text(), "active")]')->click(); diff --git a/t/selenium/controller_timeset.t b/t/selenium/controller_timeset.t index 32662b0592..f2675e4c9d 100644 --- a/t/selenium/controller_timeset.t +++ b/t/selenium/controller_timeset.t @@ -106,7 +106,7 @@ $d->fill_element('//*[@id="event_table_filter"]/label/input', 'xpath', 'Hello, i 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->wait_for_text('//*[@id="event_table"]/tbody/tr[1]/td[3]', 'every week from 2019-01-01 12:00:00 to 2019-06-05 12:20:00'), "Date/Time is correct"); +ok($d->wait_for_text('//*[@id="event_table"]/tbody/tr[1]/td[3]', 'every week on Monday from 2019-01-01 12:00:00 to 2019-06-05 12:20:00'), "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'); @@ -125,7 +125,7 @@ $d->fill_element('//*[@id="event_table_filter"]/label/input', 'xpath', 'Very imp diag("Check Details"); ok($d->wait_for_text('//*[@id="event_table"]/tbody/tr[1]/td[2]', 'Very important event'), "Description is correct"); -ok($d->wait_for_text('//*[@id="event_table"]/tbody/tr[1]/td[3]', 'every week from 2020-06-01 12:00:00 to 2020-07-01 13:00:00'), "Date/Time is correct"); +ok($d->wait_for_text('//*[@id="event_table"]/tbody/tr[1]/td[3]', 'every week on Monday from 2020-06-01 12:00:00 to 2020-07-01 13:00:00'), "Date/Time is correct"); diag("Go back to Time set page"); $d->find_element("Back", 'link_text')->click();