Bugzilla – Attachment 68122 Details for
Bug 19359
Reporting module selenium test
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19359 - Followup patch with xpaths changed to id's
Bug-19359---Followup-patch-with-xpaths-changed-to-.patch (text/plain), 24.83 KB, created by
Alex Buckley
on 2017-10-14 03:41:37 UTC
(
hide
)
Description:
Bug 19359 - Followup patch with xpaths changed to id's
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2017-10-14 03:41:37 UTC
Size:
24.83 KB
patch
obsolete
>From f1bc06976e92b7e0b47301edc9da35070b9a3e09 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 11 Oct 2017 07:24:51 +0000 >Subject: [PATCH] Bug 19359 - Followup patch with xpaths changed to id's > >Sponsored-By: Catalyst IT >--- > .../intranet-tmpl/prog/en/modules/intranet-main.tt | 2 +- > .../en/modules/reports/guided_reports_start.tt | 34 ++-- > .../prog/en/modules/reports/reports-home.tt | 16 +- > t/db_dependent/selenium/reporting_workflow.t | 103 ++++-------- > t/lib/Selenium.pm | 185 +++++++++++++++++++++ > 5 files changed, 240 insertions(+), 100 deletions(-) > create mode 100644 t/lib/Selenium.pm > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >index 2a69dd9..5c03605 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >@@ -85,7 +85,7 @@ > > [% IF ( CAN_user_reports ) %] > <li> >- <a class="icon_general icon_reports" href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> >+ <a class="icon_general icon_reports" id="reports" href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> > </li> > [% END %] > >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 5902b92..42f8e7a 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 >@@ -326,26 +326,26 @@ canned reports and writing custom SQL reports.</p> > [% IF ( CAN_user_reports_create_reports ) %] > <form action="/cgi-bin/koha/reports/guided_reports.pl"> > <input type="hidden" name="phase" value="Build new" /> >- <input type="submit" name="submit" value="Build new"/> >+ <input type="submit" name="submit" value="Build new" id="buildnew"/> > </form> > [% END %] > [% IF ( CAN_user_reports_execute_reports ) %] > <form action="/cgi-bin/koha/reports/guided_reports.pl"> > <input type="hidden" name="phase" value="Use saved"/> >- <input type="submit" name="submit" value="Use saved"/> >+ <input type="submit" name="submit" value="Use saved" id="usesaved"/> > </form> > [% END %] > [% IF ( CAN_user_reports_create_reports ) %] > <form action="/cgi-bin/koha/reports/guided_reports.pl"> > <input type="hidden" name="phase" value="Create report from SQL"/> >- <input type="submit" name="submit" value="Create report from SQL"/> >+ <input type="submit" name="submit" value="Create report from SQL" id="createreport"/> > </form> > [% END %] > <h3>Reports Dictionary</h3> > <p>Use the reports dictionary to define custom criteria to use in your reports</p> > <form action="/cgi-bin/koha/reports/dictionary.pl"> > <input type="hidden" name="phase" value="View Dictionary"/> >-<input type="submit" name="submit" value="View dictionary"/> >+<input type="submit" name="submit" value="View dictionary" id="viewdictionary"/> > </form> > [% END %] > >@@ -544,7 +544,7 @@ canned reports and writing custom SQL reports.</p> > </fieldset> > <fieldset class="action"> > <input type="hidden" name="phase" value="Report on this Area" /> >-<input type="submit" name="submit" value="Next >>" /> >+<input type="submit" name="submit" value="Next >>" id="submitfirststep" /> > > </fieldset> > </form> >@@ -569,7 +569,7 @@ canned reports and writing custom SQL reports.</p> > <fieldset class="action"> > <input type="hidden" name="phase" value="Choose this type" /> > <input type="button" name="back" value="<< Back" class="goback" /> >- <input type="submit" name="submit" value="Next >>" /> >+ <input type="submit" name="submit" value="Next >>" id="secondstepnext" /> > </fieldset> > </form> > </div> >@@ -629,7 +629,7 @@ canned reports and writing custom SQL reports.</p> > <fieldset class="action"> > <input type="hidden" name="phase" value="Choose these columns" /> > <input type="button" name="back" value="<< Back" class="goback" /> >- <input type="submit" name="submit" value="Next >>" /> >+ <input type="submit" name="submit" value="Next >>" id="thirdstepnext"/> > </fieldset> > </div> > </form> >@@ -702,7 +702,7 @@ canned reports and writing custom SQL reports.</p> > > <fieldset class="action"><input type="hidden" name="phase" value="Choose these criteria" /> > <input type="button" name="back" value="<< Back" class="goback" /> >- <input type="submit" name="submit" value="Next >>" /> </fieldset> >+ <input type="submit" name="submit" value="Next >>" id="fourthstepnext"/> </fieldset> > </form> > [% END %] > >@@ -734,7 +734,7 @@ canned reports and writing custom SQL reports.</p> > > <fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" /> > <input type="button" name="back" value="<< Back" class="goback" /> >- <input type="submit" name="submit" value="Next >>" /></fieldset> >+ <input type="submit" name="submit" value="Next >>" id="fifthstepnext"/></fieldset> > </form> > [% END %] > >@@ -766,7 +766,7 @@ canned reports and writing custom SQL reports.</p> > > <fieldset class="action"> > <input type="hidden" name="phase" value="Build report" /> >-<input type="submit" name="submit" value="Finish" /></fieldset> >+<input type="submit" name="submit" value="Finish" id="finish" /></fieldset> > </form> > [% END %] > >@@ -785,7 +785,7 @@ canned reports and writing custom SQL reports.</p> > <input type="hidden" name="cache_expiry" value="[% cache_expiry %]" /> > <p>You will need to save the report before you can execute it</p> > <fieldset class="action"><input type="hidden" name="phase" value="Save" /> >-<input type="submit" name="submit" value="Save" /> </fieldset> >+<input type="submit" name="submit" value="Save" id="save"/> </fieldset> > </form> > [% END %] > >@@ -804,7 +804,7 @@ canned reports and writing custom SQL reports.</p> > <li><label for="notes">Notes:</label> <textarea name="notes" id="notes"></textarea></li> > </ol></fieldset> > <fieldset class="action"><input type="hidden" name="phase" value="Save Report" /> >-<input type="submit" name="submit" value="Save report" /></fieldset> >+<input type="submit" name="submit" value="Save report" id="savereport" /></fieldset> > </form> > [% END %] > >@@ -920,7 +920,7 @@ canned reports and writing custom SQL reports.</p> > > <div class="pages">[% pagination_bar %]</div> > [% UNLESS ( errors ) %] >-<table> >+<table id="reporttable"> > <tr>[% FOREACH header_ro IN header_row %]<th>[% header_ro.cell %]</th>[% END %]</tr> > [% FOREACH result IN results %] > <tr> >@@ -1075,11 +1075,11 @@ Sub report:<select name="subreport"> > <h4>[% reportname %]</h4> > <ul> > [% IF ( id ) %] >- <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id %]&phase=Run%20this%20report">Run this report</a></li> >+ <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id %]&phase=Run%20this%20report" id="runreport" >Run this report</a></li> > [% END %] >- <li>Access this report from the: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports page</a></li> >- <li>Schedule this report to run using the: <a href="/cgi-bin/koha/tools/scheduler.pl">Scheduler tool</a></li> >- <li>Return to: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Guided reports</a></li> >+ <li>Access this report from the: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" id="savedreportspage">Saved reports page</a></li> >+ <li>Schedule this report to run using the: <a href="/cgi-bin/koha/tools/scheduler.pl" id="schedulartool">Scheduler tool</a></li> >+ <li>Return to: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" id="guidedreports"> Guided reports</a></li> > </ul> > [% 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 @@ > <h1>Reports</h1> > <div class="yui-u first"><h2>Guided reports</h2> > <ul> >- <li><a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a></li> >- [% IF ( CAN_user_reports_create_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build new</a></li>[% END %] >- [% IF ( CAN_user_reports_execute_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Use saved</a></li>[% END %] >- [% IF ( CAN_user_reports_create_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">Create from SQL</a></li>[% END %] >+ <li><a href="/cgi-bin/koha/reports/guided_reports.pl" id="reportwizard">Guided reports wizard</a></li> >+ [% IF ( CAN_user_reports_create_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new" id="buildnew">Build new</a></li>[% END %] >+ [% IF ( CAN_user_reports_execute_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" id="usesaved">Use saved</a></li>[% END %] >+ [% IF ( CAN_user_reports_create_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL" id="createfromsql">Create from SQL</a></li>[% END %] > </ul> > > <h5>Reports dictionary</h5> > <ul> >- <li><a href="/cgi-bin/koha/reports/dictionary.pl?phase=View%20Dictionary">View dictionary</a></li> >+ <li><a href="/cgi-bin/koha/reports/dictionary.pl?phase=View%20Dictionary" id="viewdictionary">View dictionary</a></li> > </ul> > > <h2>Statistics wizards</h2> > <ul> >- <li><a href="/cgi-bin/koha/reports/acquisitions_stats.pl">Acquisitions</a></li> >- <li><a href="/cgi-bin/koha/reports/borrowers_stats.pl">Patrons</a></li> >- <li><a href="/cgi-bin/koha/reports/catalogue_stats.pl">Catalog</a></li> >+ <li><a href="/cgi-bin/koha/reports/acquisitions_stats.pl" id="aqcwizard">Acquisitions</a></li> >+ <li><a href="/cgi-bin/koha/reports/borrowers_stats.pl" id="patronwizard">Patrons</a></li> >+ <li><a href="/cgi-bin/koha/reports/catalogue_stats.pl" id="cataloguewizard">Catalog</a></li> > <li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li> > <li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li> > <li><a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash register</a></li> >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; >-} >diff --git a/t/lib/Selenium.pm b/t/lib/Selenium.pm >new file mode 100644 >index 0000000..c993fd5 >--- /dev/null >+++ b/t/lib/Selenium.pm >@@ -0,0 +1,185 @@ >+package t::lib::Selenium; >+ >+use Modern::Perl; >+ >+use Koha::Database; >+ >+use Carp; >+use Module::Load; >+use String::Random; >+use Time::HiRes qw(gettimeofday); >+use Selenium::Waiter qw/wait_until/; >+use Try::Tiny; >+ >+my $dbh = C4::Context->dbh; >+my $login = 'koha'; >+my $password = 'koha'; >+my $base_url= 'http://'.C4::Context->preference("staffClientBaseURL")."/cgi-bin/koha/"; >+ >+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 ($sample_data, $number_of_biblios_to_insert,$borrowernumber) = @_; >+ 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}); >+ for my $i ( 1 .. $number_of_biblios_to_insert ) { >+ $dbh->do(qq|DELETE FROM biblio WHERE title = "test biblio $i"|); >+ }; >+ >+ $dbh->do(q|DELETE FROM issues where borrowernumber=?|, {}, $borrowernumber); >+ $dbh->do(q|DELETE FROM old_issues where borrowernumber=?|, {},$borrowernumber); >+ for my $i ( 1 .. $number_of_biblios_to_insert ) { >+ $dbh->do(qq|DELETE items, biblio FROM biblio INNER JOIN items ON biblio.biblionumber = items.biblionumber WHERE biblio.title ="test biblio$i"|); >+ }; >+} >+ >+sub time_diff { >+ my ($prev_time, $lib) = (@_); >+ my $now = gettimeofday; >+ warn "CP $lib = " . sprintf("%.2f", $now - $prev_time ) . "\n"; >+ $prev_time = $now; >+} >+ >+sub pause_driver { >+ my ($driver, $element) = @_; >+ $driver->set_implicit_wait_timeout(30000); >+ my $elem_exists = wait_until {$driver->find_element_by_xpath('$element')}; >+ >+ if ($elem_exists) { >+ $driver->find_element_by_xpath('$element')->click; >+ } >+} >+ >+ >+=head1 NAME >+ >+t::lib::Selenium.pm - Koha module for common Selenium functions >+ >+=head1 SYNOPSIS >+ >+ >+=head1 DESCRIPTION >+ >+This Perl module >+ >+ >+This module automatically creates database records for you. >+If needed, records for foreign keys are created too. >+Values will be randomly generated if not passed to TestBuilder. >+Note that you should wrap these actions in a transaction yourself. >+ >+=head1 METHODS >+ >+=head2 new >+ >+ my $builder = t::lib::TestBuilder->new; >+ >+ Constructor - Returns the object TestBuilder >+ >+=head2 schema >+ >+ my $schema = $builder->schema; >+ >+ Getter - Returns the schema of DBIx::Class >+ >+=head2 delete >+ >+ $builder->delete({ >+ source => $source, >+ records => $patron, # OR: records => [ $patron, ... ], >+ }); >+ >+ Delete individual records, created by builder. >+ Returns the number of delete attempts, or undef. >+ >+=head2 build >+ >+ $builder->build({ source => $source_name, value => $value }); >+ >+ Create a test record in the table, represented by $source_name. >+ The name is required and must conform to the DBIx::Class schema. >+ Values may be specified by the optional $value hashref. Will be >+ randomized otherwise. >+ If needed, TestBuilder creates linked records for foreign keys. >+ Returns the values of the new record as a hashref, or undef if >+ the record could not be created. >+ >+ Note that build also supports recursive hash references inside the >+ value hash for foreign key columns, like: >+ value => { >+ column1 => 'some_value', >+ fk_col2 => { >+ columnA => 'another_value', >+ } >+ } >+ The hash for fk_col2 here means: create a linked record with build >+ where columnA has this value. In case of a composite FK the hashes >+ are merged. >+ >+ Realize that passing primary key values to build may result in undef >+ if a record with that primary key already exists. >+ >+=head2 build_object >+ >+Given a plural Koha::Object-derived class, it creates a random element, and >+returns the corresponding Koha::Object. >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' [, value => { ... }] }); >+ >+=head1 AUTHOR >+ >+Alex Buckley <alexbuckley@catalyst.net.nz> >+ >+Catalyst Koha Development Team >+ >+=head1 COPYRIGHT >+ >+Copyright 2017 - Catalyst IT >+ >+=head1 LICENSE >+ >+This file is part of Koha. >+ >+Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by >+the Free Software Foundation; either version 3 of the License, or (at your option) any later version. >+ >+Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+ >+You should have received a copy of the GNU General Public License along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+=cut >+ >+1; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19359
:
67342
|
67925
|
67926
|
68120
|
68121
| 68122