From ef68ce9c428f8ea516812d5a6540df2ff4a57c66 Mon Sep 17 00:00:00 2001
From: Alex Buckley
Date: Wed, 11 Oct 2017 07:24:51 +0000
Subject: [PATCH] Bug 19359 - Followup patch with xpaths changed to id's
---
.../en/modules/reports/guided_reports_start.tt | 34 +++----
.../prog/en/modules/reports/reports-home.tt | 16 ++--
t/db_dependent/selenium/reporting_workflow.t | 103 ++++++---------------
3 files changed, 54 insertions(+), 99 deletions(-)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
index 4c3b47e..3e3579a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
@@ -328,26 +328,26 @@ canned reports and writing custom SQL reports.
[% IF ( CAN_user_reports_create_reports ) %]
[% END %]
[% IF ( CAN_user_reports_execute_reports ) %]
[% END %]
[% IF ( CAN_user_reports_create_reports ) %]
[% END %]
Reports Dictionary
Use the reports dictionary to define custom criteria to use in your reports
[% END %]
@@ -546,7 +546,7 @@ canned reports and writing custom SQL reports.
-
+
@@ -571,7 +571,7 @@ canned reports and writing custom SQL reports.
-
+
@@ -631,7 +631,7 @@ canned reports and writing custom SQL reports.
-
+
@@ -704,7 +704,7 @@ canned reports and writing custom SQL reports.
-
+
[% END %]
@@ -736,7 +736,7 @@ canned reports and writing custom SQL reports.
-
+
[% END %]
@@ -768,7 +768,7 @@ canned reports and writing custom SQL reports.
-
+
[% END %]
@@ -787,7 +787,7 @@ canned reports and writing custom SQL reports.
You will need to save the report before you can execute it
-
+
[% END %]
@@ -806,7 +806,7 @@ canned reports and writing custom SQL reports.
Notes:
-
+
[% END %]
@@ -922,7 +922,7 @@ canned reports and writing custom SQL reports.
[% pagination_bar %]
[% UNLESS ( errors ) %]
-
+
[% FOREACH header_ro IN header_row %][% header_ro.cell %] [% END %]
[% FOREACH result IN results %]
@@ -1077,11 +1077,11 @@ Sub report:
[% reportname %]
[% END %]
[% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt
index 6b47b70..e20cb99 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt
@@ -17,22 +17,22 @@
Reports
Guided reports
Reports dictionary
Statistics wizards
- Acquisitions
- Patrons
- Catalog
+ Acquisitions
+ Patrons
+ Catalog
Circulation
Serials
Cash register
diff --git a/t/db_dependent/selenium/reporting_workflow.t b/t/db_dependent/selenium/reporting_workflow.t
index 28a5ca9..bac9122 100644
--- a/t/db_dependent/selenium/reporting_workflow.t
+++ b/t/db_dependent/selenium/reporting_workflow.t
@@ -31,6 +31,7 @@ use Test::More tests => 7;
use MARC::Record;
use MARC::Field;
use Selenium::Remote::Driver::Firefox::Profile;
+use t::lib::Selenium;
my $dbh = C4::Context->dbh;
my $login = 'koha';
@@ -74,8 +75,8 @@ SKIP: {
$prev_time = $start;
$driver->get($base_url."mainpage.pl");
like( $driver->get_title(), qr(Log in to Koha), );
- auth( $driver, $login, $password );
- time_diff("main");
+ t::lib::Selenium::auth( $driver, $login, $password );
+ t::lib::Selenium::time_diff($prev_time, "main");
#Add biblio
$borrowernumber = $dbh->selectcol_arrayref(q|SELECT borrowernumber FROM borrowers WHERE userid=?|, {}, $sample_data->{patron}{userid} )->[0];
@@ -98,7 +99,7 @@ SKIP: {
my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
push @biblionumbers, $biblionumber;
}
- time_diff("add biblio");
+ t::lib::Selenium::time_diff($prev_time, "add biblio");
#Add items to the biblio
my $itemtype = $dbh->selectcol_arrayref(q|SELECT itemtype FROM itemtypes|);
@@ -108,7 +109,7 @@ SKIP: {
$driver->get($base_url."/cataloguing/additem.pl?biblionumber=$biblionumber");
like( $driver->get_title(), qr(test biblio \d+ by test author), );
my $form = $driver->find_element('//form[@name="f"]');
- my $inputs = $driver->find_child_elements($form, '//input[@ type="text"]');
+ my $inputs = $driver->find_child_elements($form, '//input[@type="text"]');
for my $input ( @$inputs ) {
next if $input->is_hidden();
my $id = $input->get_attribute('id');
@@ -122,38 +123,39 @@ SKIP: {
$dbh->do(q|UPDATE biblioitems SET itemtype=? WHERE biblionumber=?|, {}, $itemtype, $biblionumber);
$dbh->do(q|UPDATE items SET itype=? WHERE biblionumber=?|,{}, $itemtype, $biblionumber);
}
- time_diff("add items");
+ t::lib::Selenium::time_diff($prev_time, "add items");
#Navigate into Reports and create a new report
$driver->get($base_url."mainpage.pl");
- $driver->find_element_by_xpath('/html/body/div[4]/div/div[1]/div/div[1]/div[2]/div/ul/li[3]/a')->click;
+ $driver->find_element('//a[@id="reports"]')->click;
$driver->pause(20000);
- $driver->find_element_by_xpath('/html/body/div[4]/div/div[1]/div/div[1]/ul[1]/li[2]/a')->click;
+ $driver->find_element('//a[@id="reportwizard"]')->click;
$driver->pause(20000);
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[1]/ol/li[1]/select')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[1]/ol/li[1]/select/option[2]')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[2]/input[2]')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div[1]/form/fieldset[2]/input[3]')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset/div/div[1]/div[1]/select/optgroup[1]/option[1]')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset/div/div[1]/div[2]/input[1]')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset/div/div[1]/div[1]/select/optgroup[1]/option[2]')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset/div/div[1]/div[2]/input[1]')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/div/fieldset/input[3]')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[2]/input[3]')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[2]/input[3]')->click;
+ $driver->find_element('//input[@id="buildnew"]')->click;
+ $driver->find_element('//select[@id="area"]')->click;
+ $driver->find_element('//option[@value="CAT"]')->click;
+ $driver->find_element('//input[@id="submitfirststep"]')->click;
+ $driver->find_element('//input[@id="secondstepnext"]')->click;
+ $driver->find_element('//option[@value="items.itemnumber"]')->click;
+ $driver->find_element('//input[@id="addColumn"]')->click;
+ $driver->find_element('//option[@value="items.biblionumber"]')->click;
+ $driver->find_element('//input[@id="addColumn"]')->click;
+ $driver->find_element('//input[@id="thirdstepnext"]')->click;
+ $driver->find_element('//input[@id="fourthstepnext"]')->click;
+ $driver->find_element('//input[@id="fifthstepnext"]')->click;
$driver->pause(20000);
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[2]/input[2]')->click;
+ $driver->find_element('//input[@id="finish"]')->click;
$driver->pause(20000);
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset/input[2]')->click;
+ $driver->find_element('//input[@id="save"]')->click;
$driver->pause(20000);
$driver->find_element('//input[@id="reportname"]')->send_keys("Test report");
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[1]/ol/li[4]/textarea')->send_keys("This test retrieves item information from the catalog");
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[2]/input[2]')->click;
- $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/ul/li[1]/a')->click;
- if ($driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/table/tbody/tr[1]/th[1]')) {
- time_diff("Report successfully created");
+ $driver->find_element('//textarea[@id="notes"]')->send_keys("This test retrieves item information from the catalog");
+ $driver->find_element('//input[@id="savereport"]')->click;
+ $driver->find_element('//a[@id="runreport"]')->click;
+ if ($driver->find_element('//table[@id="reporttable"]')) {
+ t::lib::Selenium::time_diff($prev_time, "Report successfully created");
} else {
- time_diff("Report not successfully created");
+ t::lib::Selenium::time_diff($prev_time, "Report not successfully created");
}
close $fh;
@@ -161,52 +163,5 @@ SKIP: {
};
END {
- cleanup() if $cleanup_needed;
+ t::lib::Selenium::cleanup($sample_data,$number_of_biblios_to_insert,$borrowernumber) if $cleanup_needed;
};
-
-sub auth {
- my ( $driver, $login, $password) = @_;
- fill_form( $driver, { userid => 'koha', password => 'koha' } );
- my $login_button = $driver->find_element('//input[@id="submit"]');
- $login_button->submit();
-}
-
-sub patron_auth {
- my ( $driver,$patronusername, $patronpassword) = @_;
- fill_form( $driver, { userid => $patronusername, password => $patronpassword } );
- my $login_button = $driver->find_element('//input[@id="submit"]');
- $login_button->submit();
-}
-
-sub patron_opac_auth {
- my ( $driver,$patronusername, $patronpassword) = @_;
- fill_form( $driver, { userid => $patronusername, password => $patronpassword } );
- my $login_button = $driver->find_element('//input[@value="Log in"]');
- $login_button->submit();
-}
-
-sub fill_form {
- my ( $driver, $values ) = @_;
- while ( my ( $id, $value ) = each %$values ) {
- my $element = $driver->find_element('//*[@id="'.$id.'"]');
- my $tag = $element->get_tag_name();
- if ( $tag eq 'input' ) {
- $driver->find_element('//input[@id="'.$id.'"]')->send_keys($value);
- } elsif ( $tag eq 'select' ) {
- $driver->find_element('//select[@id="'.$id.'"]/option[@value="'.$value.'"]')->click;
- }
- }
-}
-
-sub cleanup {
- my $dbh = C4::Context->dbh;
- $dbh->do(q|DELETE FROM categories WHERE categorycode = ?|, {}, $sample_data->{category}{categorycode});
- $dbh->do(q|DELETE FROM borrowers WHERE userid = ?|, {}, $sample_data->{patron}{userid});
-}
-
-sub time_diff {
- my $lib = shift;
- my $now = gettimeofday;
- warn "CP $lib = " . sprintf("%.2f", $now - $prev_time ) . "\n";
- $prev_time = $now;
-}
--
2.1.4