From 309356249bd74ec9251a07b75d316ba43d2e3704 Mon Sep 17 00:00:00 2001 From: Nico Schedel Date: Fri, 20 Mar 2020 10:15:27 +0100 Subject: [PATCH] TT#78161 selenium: fix search calls to work better with search field caching controller_billing.t, controller_profileset.t, controller_timeset.t: - search field caching caused some problems, where elements would not show up because cached search would not find elements which the names got updated Change-Id: I11ae4dca9c07a720f2d491878402cd36650b015d --- t/selenium/controller_billing.t | 3 +++ t/selenium/controller_profileset.t | 12 ++++++++++-- t/selenium/controller_timeset.t | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/t/selenium/controller_billing.t b/t/selenium/controller_billing.t index b8fe153109..e40fdf2c8c 100644 --- a/t/selenium/controller_billing.t +++ b/t/selenium/controller_billing.t @@ -346,6 +346,9 @@ $d->fill_element('#end', 'css', "2019-01-01 23:59:59"); $d->find_element('#save', 'css')->click(); diag("Check if Date Definition is correct"); +$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'); is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), 'Special offpeak entry successfully updated', 'Correct Alert was shown'); ok($d->find_element_by_xpath('//*[@id="date_definition_table"]//tr[1]/td[contains(text(), "2018-01-01 00:00:00")]'), 'Start Date Definition is correct'); ok($d->find_element_by_xpath('//*[@id="date_definition_table"]//tr[1]/td[contains(text(), "2019-01-01 23:59:59")]'), 'End Date Definition is correct'); diff --git a/t/selenium/controller_profileset.t b/t/selenium/controller_profileset.t index a882ab9b0b..3b16e03960 100644 --- a/t/selenium/controller_profileset.t +++ b/t/selenium/controller_profileset.t @@ -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 Selenium::Remote::WDKeys; my ($port) = @_; my $d = Selenium::Collection::Functions::create_driver($port); @@ -108,7 +109,7 @@ $d->fill_element('//*[@id="subscriber_profile_table_filter"]/label/input', 'xpat 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"); +diag("Check Profile details"); ok($d->find_element_by_xpath('//*[@id="subscriber_profile_table"]//tr[1]/td[contains(text(), "' . $profilename . '")]', $profilename), 'Name is correct'); ok($d->find_element_by_xpath('//*[@id="subscriber_profile_table"]//tr[1]/td[contains(text(), "This is a description. It describes things")]'), 'Description is correct'); ok($d->find_element_by_xpath('//*[@id="subscriber_profile_table"]//tr[1]/td[contains(text(), "' . $setname . '")]', $setname), 'Profile Set is correct'); @@ -121,7 +122,12 @@ $d->fill_element('//*[@id="name"]', 'xpath', $profilename); $d->fill_element('//*[@id="description"]', 'xpath', 'Very very useful description'); $d->find_element('//*[@id="save"]')->click(); -diag("Check profile details"); +diag("Search 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->find_element_by_xpath('//*[@id="subscriber_profile_table"]//tr[1]/td[contains(text(), "' . $profilename . '")]', $profilename), 'Name is correct'); ok($d->find_element_by_xpath('//*[@id="subscriber_profile_table"]//tr[1]/td[contains(text(), "Very very useful description")]'), 'Description is correct'); ok($d->find_element_by_xpath('//*[@id="subscriber_profile_table"]//tr[1]/td[contains(text(), "' . $setname . '")]', $setname), 'Profile Set is correct'); @@ -168,6 +174,8 @@ $d->select_if_unselected('//*[@id="set_default"]', 'xpath'); $d->find_element('//*[@id="save"]')->click(); diag("Check if cloned Profile is now default"); +$d->find_element_by_xpath('//*[@id="subscriber_profile_table_filter"]/label/input')->clear(); +$d->find_element_by_xpath('//*[@id="subscriber_profile_table_filter"]/label/input')->send_keys(KEYS->{'return'}); is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Subscriber profile successfully updated", 'Correct Alert was shown'); ok($d->find_element_by_xpath('//*[@id="subscriber_profile_table"]//tr/td[contains(text(), "' . $cloneprofilename . '")]//..//td[contains(text(), "1")]'), 'Cloned Profile is now default'); ok($d->find_element_by_xpath('//*[@id="subscriber_profile_table"]//tr/td[contains(text(), "' . $profilename . '")]//..//td[contains(text(), "0")]'), 'Original Profile is no longer default'); diff --git a/t/selenium/controller_timeset.t b/t/selenium/controller_timeset.t index bd66717896..6f60819086 100644 --- a/t/selenium/controller_timeset.t +++ b/t/selenium/controller_timeset.t @@ -129,6 +129,12 @@ $d->unselect_if_selected('//*[@id="byday.weekdays.4"]'); $d->fill_element('//*[@id="byday.weekdaynumber"]', 'xpath', '+2FR'); $d->find_element('//*[@id="save"]')->click(); +diag("Search Event"); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), 'Event entry successfully created', 'Correct Alert was shown'); +$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"); is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), 'Event entry successfully created', 'Correct Alert was shown'); ok($d->find_element_by_xpath('//*[@id="event_table"]//tr[1]/td[contains(text(), "Very important event")]'), "Description is correct");