View | Details | Raw Unified | Return to bug 19359
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt (-1 / +1 lines)
Lines 85-91 Link Here
85
85
86
                    [% IF ( CAN_user_reports ) %]
86
                    [% IF ( CAN_user_reports ) %]
87
                    <li>
87
                    <li>
88
                        <a class="icon_general icon_reports" href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
88
                        <a class="icon_general icon_reports" id="reports" href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
89
                    </li>
89
                    </li>
90
                    [% END %]
90
                    [% END %]
91
91
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-17 / +17 lines)
Lines 326-351 canned reports and writing custom SQL reports.</p> Link Here
326
        [% IF ( CAN_user_reports_create_reports ) %]
326
        [% IF ( CAN_user_reports_create_reports ) %]
327
        <form action="/cgi-bin/koha/reports/guided_reports.pl">
327
        <form action="/cgi-bin/koha/reports/guided_reports.pl">
328
            <input type="hidden" name="phase" value="Build new" />
328
            <input type="hidden" name="phase" value="Build new" />
329
            <input type="submit" name="submit" value="Build new"/>
329
            <input type="submit" name="submit" value="Build new" id="buildnew"/>
330
        </form>
330
        </form>
331
        [% END %]
331
        [% END %]
332
        [% IF ( CAN_user_reports_execute_reports ) %]
332
        [% IF ( CAN_user_reports_execute_reports ) %]
333
        <form action="/cgi-bin/koha/reports/guided_reports.pl">
333
        <form action="/cgi-bin/koha/reports/guided_reports.pl">
334
            <input type="hidden" name="phase" value="Use saved"/>
334
            <input type="hidden" name="phase" value="Use saved"/>
335
            <input type="submit" name="submit" value="Use saved"/>
335
            <input type="submit" name="submit" value="Use saved" id="usesaved"/>
336
        </form>
336
        </form>
337
        [% END %]
337
        [% END %]
338
        [% IF ( CAN_user_reports_create_reports ) %]
338
        [% IF ( CAN_user_reports_create_reports ) %]
339
        <form action="/cgi-bin/koha/reports/guided_reports.pl">
339
        <form action="/cgi-bin/koha/reports/guided_reports.pl">
340
            <input type="hidden" name="phase" value="Create report from SQL"/>
340
            <input type="hidden" name="phase" value="Create report from SQL"/>
341
            <input type="submit" name="submit" value="Create report from SQL"/>
341
            <input type="submit" name="submit" value="Create report from SQL" id="createreport"/>
342
        </form>
342
        </form>
343
        [% END %]
343
        [% END %]
344
<h3>Reports Dictionary</h3>
344
<h3>Reports Dictionary</h3>
345
<p>Use the reports dictionary to define custom criteria to use in your reports</p>
345
<p>Use the reports dictionary to define custom criteria to use in your reports</p>
346
<form action="/cgi-bin/koha/reports/dictionary.pl">
346
<form action="/cgi-bin/koha/reports/dictionary.pl">
347
<input type="hidden" name="phase" value="View Dictionary"/>
347
<input type="hidden" name="phase" value="View Dictionary"/>
348
<input type="submit" name="submit" value="View dictionary"/>
348
<input type="submit" name="submit" value="View dictionary" id="viewdictionary"/>
349
</form>
349
</form>
350
[% END %]
350
[% END %]
351
351
Lines 544-550 canned reports and writing custom SQL reports.</p> Link Here
544
</fieldset>
544
</fieldset>
545
<fieldset class="action">
545
<fieldset class="action">
546
<input type="hidden" name="phase" value="Report on this Area" />
546
<input type="hidden" name="phase" value="Report on this Area" />
547
<input type="submit" name="submit" value="Next &gt;&gt;" />
547
<input type="submit" name="submit" value="Next &gt;&gt;" id="submitfirststep" />
548
548
549
</fieldset>
549
</fieldset>
550
</form>
550
</form>
Lines 569-575 canned reports and writing custom SQL reports.</p> Link Here
569
<fieldset class="action">
569
<fieldset class="action">
570
    <input type="hidden" name="phase" value="Choose this type" />
570
    <input type="hidden" name="phase" value="Choose this type" />
571
    <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
571
    <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
572
    <input type="submit" name="submit" value="Next &gt;&gt;" />
572
    <input type="submit" name="submit" value="Next &gt;&gt;" id="secondstepnext" />
573
</fieldset>
573
</fieldset>
574
</form>
574
</form>
575
</div>
575
</div>
Lines 629-635 canned reports and writing custom SQL reports.</p> Link Here
629
<fieldset class="action">
629
<fieldset class="action">
630
    <input type="hidden" name="phase" value="Choose these columns" />
630
    <input type="hidden" name="phase" value="Choose these columns" />
631
    <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
631
    <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
632
    <input type="submit" name="submit" value="Next &gt;&gt;" />
632
    <input type="submit" name="submit" value="Next &gt;&gt;" id="thirdstepnext"/>
633
</fieldset>
633
</fieldset>
634
</div>
634
</div>
635
</form>
635
</form>
Lines 702-708 canned reports and writing custom SQL reports.</p> Link Here
702
702
703
<fieldset class="action"><input type="hidden" name="phase" value="Choose these criteria" />
703
<fieldset class="action"><input type="hidden" name="phase" value="Choose these criteria" />
704
    <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
704
    <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
705
    <input type="submit" name="submit" value="Next &gt;&gt;" /> </fieldset>
705
    <input type="submit" name="submit" value="Next &gt;&gt;" id="fourthstepnext"/> </fieldset>
706
</form>
706
</form>
707
[% END %]
707
[% END %]
708
708
Lines 734-740 canned reports and writing custom SQL reports.</p> Link Here
734
734
735
<fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" />
735
<fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" />
736
    <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
736
    <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
737
    <input type="submit" name="submit" value="Next &gt;&gt;" /></fieldset>
737
    <input type="submit" name="submit" value="Next &gt;&gt;" id="fifthstepnext"/></fieldset>
738
</form>
738
</form>
739
[% END %]
739
[% END %]
740
740
Lines 766-772 canned reports and writing custom SQL reports.</p> Link Here
766
766
767
<fieldset class="action">
767
<fieldset class="action">
768
<input type="hidden" name="phase" value="Build report" />
768
<input type="hidden" name="phase" value="Build report" />
769
<input type="submit" name="submit" value="Finish" /></fieldset>
769
<input type="submit" name="submit" value="Finish" id="finish" /></fieldset>
770
</form>
770
</form>
771
[% END %]
771
[% END %]
772
772
Lines 785-791 canned reports and writing custom SQL reports.</p> Link Here
785
<input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
785
<input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
786
<p>You will need to save the report before you can execute it</p>
786
<p>You will need to save the report before you can execute it</p>
787
<fieldset class="action"><input type="hidden" name="phase" value="Save" />  
787
<fieldset class="action"><input type="hidden" name="phase" value="Save" />  
788
<input type="submit" name="submit" value="Save" />  </fieldset>
788
<input type="submit" name="submit" value="Save" id="save"/>  </fieldset>
789
</form>
789
</form>
790
[% END %]
790
[% END %]
791
791
Lines 804-810 canned reports and writing custom SQL reports.</p> Link Here
804
    <li><label for="notes">Notes:</label> <textarea name="notes" id="notes"></textarea></li>
804
    <li><label for="notes">Notes:</label> <textarea name="notes" id="notes"></textarea></li>
805
</ol></fieldset>
805
</ol></fieldset>
806
<fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
806
<fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
807
<input type="submit" name="submit" value="Save report" /></fieldset>
807
<input type="submit" name="submit" value="Save report" id="savereport" /></fieldset>
808
</form>
808
</form>
809
[% END %]
809
[% END %]
810
810
Lines 920-926 canned reports and writing custom SQL reports.</p> Link Here
920
920
921
<div class="pages">[% pagination_bar %]</div>
921
<div class="pages">[% pagination_bar %]</div>
922
[% UNLESS ( errors ) %]
922
[% UNLESS ( errors ) %]
923
<table>
923
<table id="reporttable">
924
<tr>[% FOREACH header_ro IN header_row %]<th>[% header_ro.cell %]</th>[% END %]</tr>
924
<tr>[% FOREACH header_ro IN header_row %]<th>[% header_ro.cell %]</th>[% END %]</tr>
925
[% FOREACH result IN results %]
925
[% FOREACH result IN results %]
926
<tr>
926
<tr>
Lines 1075-1085 Sub report:<select name="subreport"> Link Here
1075
<h4>[% reportname %]</h4>
1075
<h4>[% reportname %]</h4>
1076
<ul>
1076
<ul>
1077
    [% IF ( id ) %]
1077
    [% IF ( id ) %]
1078
    <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id %]&amp;phase=Run%20this%20report">Run this report</a></li>
1078
    <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id %]&amp;phase=Run%20this%20report" id="runreport" >Run this report</a></li>
1079
    [% END %]
1079
    [% END %]
1080
    <li>Access this report from the: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports page</a></li>
1080
    <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>
1081
    <li>Schedule this report to run using the: <a href="/cgi-bin/koha/tools/scheduler.pl">Scheduler tool</a></li>
1081
    <li>Schedule this report to run using the: <a href="/cgi-bin/koha/tools/scheduler.pl" id="schedulartool">Scheduler tool</a></li>
1082
    <li>Return to: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Guided reports</a></li>
1082
    <li>Return to: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" id="guidedreports"> Guided reports</a></li>
1083
</ul>
1083
</ul>
1084
[% END %]
1084
[% END %]
1085
[% END %]
1085
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt (-8 / +8 lines)
Lines 17-38 Link Here
17
    <h1>Reports</h1>
17
    <h1>Reports</h1>
18
    <div class="yui-u first"><h2>Guided reports</h2>
18
    <div class="yui-u first"><h2>Guided reports</h2>
19
        <ul>
19
        <ul>
20
            <li><a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a></li>
20
            <li><a href="/cgi-bin/koha/reports/guided_reports.pl" id="reportwizard">Guided reports wizard</a></li>
21
            [% IF ( CAN_user_reports_create_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build new</a></li>[% END %]
21
            [% 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 %]
22
            [% IF ( CAN_user_reports_execute_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Use saved</a></li>[% END %]
22
            [% 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 %]
23
            [% 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 %]
23
            [% 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 %]
24
        </ul>
24
        </ul>
25
25
26
        <h5>Reports dictionary</h5>
26
        <h5>Reports dictionary</h5>
27
        <ul>
27
        <ul>
28
            <li><a href="/cgi-bin/koha/reports/dictionary.pl?phase=View%20Dictionary">View dictionary</a></li>
28
            <li><a href="/cgi-bin/koha/reports/dictionary.pl?phase=View%20Dictionary" id="viewdictionary">View dictionary</a></li>
29
        </ul>
29
        </ul>
30
30
31
        <h2>Statistics wizards</h2>
31
        <h2>Statistics wizards</h2>
32
        <ul>
32
        <ul>
33
            <li><a href="/cgi-bin/koha/reports/acquisitions_stats.pl">Acquisitions</a></li>
33
            <li><a href="/cgi-bin/koha/reports/acquisitions_stats.pl" id="aqcwizard">Acquisitions</a></li>
34
            <li><a href="/cgi-bin/koha/reports/borrowers_stats.pl">Patrons</a></li>
34
            <li><a href="/cgi-bin/koha/reports/borrowers_stats.pl" id="patronwizard">Patrons</a></li>
35
            <li><a href="/cgi-bin/koha/reports/catalogue_stats.pl">Catalog</a></li>
35
            <li><a href="/cgi-bin/koha/reports/catalogue_stats.pl" id="cataloguewizard">Catalog</a></li>
36
            <li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li>
36
            <li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li>
37
            <li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li>
37
            <li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li>
38
            <li><a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash register</a></li>
38
            <li><a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash register</a></li>
(-)a/t/db_dependent/selenium/reporting_workflow.t (-74 / +29 lines)
Lines 31-36 use Test::More tests => 7; Link Here
31
use MARC::Record;
31
use MARC::Record;
32
use MARC::Field;
32
use MARC::Field;
33
use Selenium::Remote::Driver::Firefox::Profile;
33
use Selenium::Remote::Driver::Firefox::Profile;
34
use t::lib::Selenium;
34
35
35
my $dbh = C4::Context->dbh;
36
my $dbh = C4::Context->dbh;
36
my $login = 'koha';
37
my $login = 'koha';
Lines 74-81 SKIP: { Link Here
74
    $prev_time = $start;
75
    $prev_time = $start;
75
    $driver->get($base_url."mainpage.pl");
76
    $driver->get($base_url."mainpage.pl");
76
    like( $driver->get_title(), qr(Log in to Koha), );
77
    like( $driver->get_title(), qr(Log in to Koha), );
77
    auth( $driver, $login, $password );
78
    t::lib::Selenium::auth( $driver, $login, $password );
78
    time_diff("main");
79
    t::lib::Selenium::time_diff($prev_time, "main");
79
80
80
    #Add biblio
81
    #Add biblio
81
    $borrowernumber = $dbh->selectcol_arrayref(q|SELECT borrowernumber FROM borrowers WHERE userid=?|, {}, $sample_data->{patron}{userid} )->[0];
82
    $borrowernumber = $dbh->selectcol_arrayref(q|SELECT borrowernumber FROM borrowers WHERE userid=?|, {}, $sample_data->{patron}{userid} )->[0];
Lines 98-104 SKIP: { Link Here
98
        my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio,     '');
99
        my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio,     '');
99
        push @biblionumbers, $biblionumber;
100
        push @biblionumbers, $biblionumber;
100
    }
101
    }
101
    time_diff("add biblio");
102
    t::lib::Selenium::time_diff($prev_time, "add biblio");
102
103
103
    #Add items to the biblio
104
    #Add items to the biblio
104
    my $itemtype = $dbh->selectcol_arrayref(q|SELECT itemtype FROM itemtypes|);
105
    my $itemtype = $dbh->selectcol_arrayref(q|SELECT itemtype FROM itemtypes|);
Lines 108-114 SKIP: { Link Here
108
        $driver->get($base_url."/cataloguing/additem.pl?biblionumber=$biblionumber");
109
        $driver->get($base_url."/cataloguing/additem.pl?biblionumber=$biblionumber");
109
        like( $driver->get_title(), qr(test biblio \d+ by test author), );
110
        like( $driver->get_title(), qr(test biblio \d+ by test author), );
110
        my $form = $driver->find_element('//form[@name="f"]');
111
        my $form = $driver->find_element('//form[@name="f"]');
111
        my $inputs = $driver->find_child_elements($form, '//input[@    type="text"]');
112
        my $inputs = $driver->find_child_elements($form, '//input[@type="text"]');
112
        for my $input ( @$inputs ) {
113
        for my $input ( @$inputs ) {
113
            next if $input->is_hidden();
114
            next if $input->is_hidden();
114
            my $id = $input->get_attribute('id');
115
            my $id = $input->get_attribute('id');
Lines 122-159 SKIP: { Link Here
122
         $dbh->do(q|UPDATE biblioitems SET itemtype=? WHERE biblionumber=?|, {}, $itemtype, $biblionumber);
123
         $dbh->do(q|UPDATE biblioitems SET itemtype=? WHERE biblionumber=?|, {}, $itemtype, $biblionumber);
123
         $dbh->do(q|UPDATE items SET itype=? WHERE biblionumber=?|,{}, $itemtype, $biblionumber);
124
         $dbh->do(q|UPDATE items SET itype=? WHERE biblionumber=?|,{}, $itemtype, $biblionumber);
124
    }
125
    }
125
    time_diff("add items");
126
    t::lib::Selenium::time_diff($prev_time, "add items");
126
127
127
    #Navigate into Reports and create a new report
128
    #Navigate into Reports and create a new report
128
    $driver->get($base_url."mainpage.pl");
129
    $driver->get($base_url."mainpage.pl");
129
    $driver->find_element_by_xpath('/html/body/div[4]/div/div[1]/div/div[1]/div[2]/div/ul/li[3]/a')->click;
130
    $driver->find_element('//a[@id="reports"]')->click;
130
    $driver->pause(20000);
131
    $driver->pause(20000);
131
    $driver->find_element_by_xpath('/html/body/div[4]/div/div[1]/div/div[1]/ul[1]/li[2]/a')->click;
132
    $driver->find_element('//a[@id="reportwizard"]')->click;
132
    $driver->pause(20000);
133
    $driver->pause(20000);
133
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[1]/ol/li[1]/select')->click;
134
    $driver->find_element('//input[@id="buildnew"]')->click;
134
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[1]/ol/li[1]/select/option[2]')->click;
135
    $driver->find_element('//select[@id="area"]')->click;
135
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[2]/input[2]')->click;
136
    $driver->find_element('//option[@value="CAT"]')->click;
136
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div[1]/form/fieldset[2]/input[3]')->click;
137
    $driver->find_element('//input[@id="submitfirststep"]')->click;
137
    $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;
138
    $driver->find_element('//input[@id="secondstepnext"]')->click;
138
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset/div/div[1]/div[2]/input[1]')->click;
139
    $driver->find_element('//option[@value="items.itemnumber"]')->click;
139
    $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;
140
    $driver->find_element('//input[@id="addColumn"]')->click;
140
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset/div/div[1]/div[2]/input[1]')->click;
141
    $driver->find_element('//option[@value="items.biblionumber"]')->click;
141
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/div/fieldset/input[3]')->click;
142
    $driver->find_element('//input[@id="addColumn"]')->click;
142
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[2]/input[3]')->click;
143
    $driver->find_element('//input[@id="thirdstepnext"]')->click;
143
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[2]/input[3]')->click;
144
    $driver->find_element('//input[@id="fourthstepnext"]')->click;
145
    $driver->find_element('//input[@id="fifthstepnext"]')->click;
144
    $driver->pause(20000);
146
    $driver->pause(20000);
145
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[2]/input[2]')->click;
147
    $driver->find_element('//input[@id="finish"]')->click;
146
    $driver->pause(20000);
148
    $driver->pause(20000);
147
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset/input[2]')->click;
149
    $driver->find_element('//input[@id="save"]')->click;
148
    $driver->pause(20000);
150
    $driver->pause(20000);
149
    $driver->find_element('//input[@id="reportname"]')->send_keys("Test report");
151
    $driver->find_element('//input[@id="reportname"]')->send_keys("Test report");
150
    $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");
152
    $driver->find_element('//textarea[@id="notes"]')->send_keys("This test retrieves item information from the catalog");
151
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/form/fieldset[2]/input[2]')->click;
153
    $driver->find_element('//input[@id="savereport"]')->click;
152
    $driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/ul/li[1]/a')->click;
154
    $driver->find_element('//a[@id="runreport"]')->click;
153
    if ($driver->find_element_by_xpath('/html/body/div[5]/div/div[1]/div/table/tbody/tr[1]/th[1]')) {
155
    if ($driver->find_element('//table[@id="reporttable"]')) {
154
        time_diff("Report successfully created");
156
        t::lib::Selenium::time_diff($prev_time, "Report successfully created");
155
    } else {
157
    } else {
156
        time_diff("Report not successfully created");
158
        t::lib::Selenium::time_diff($prev_time, "Report not successfully created");
157
    }
159
    }
158
160
159
    close $fh;
161
    close $fh;
Lines 161-212 SKIP: { Link Here
161
};
163
};
162
164
163
END {
165
END {
164
    cleanup() if $cleanup_needed;
166
    t::lib::Selenium::cleanup($sample_data,$number_of_biblios_to_insert,$borrowernumber) if $cleanup_needed;
165
};
167
};
166
167
sub auth {
168
    my ( $driver, $login, $password) = @_;
169
    fill_form( $driver, { userid => 'koha', password => 'koha' } );
170
    my $login_button = $driver->find_element('//input[@id="submit"]');
171
    $login_button->submit();
172
}
173
174
sub patron_auth {
175
    my ( $driver,$patronusername, $patronpassword) = @_;
176
    fill_form( $driver, { userid => $patronusername, password => $patronpassword } );
177
    my $login_button = $driver->find_element('//input[@id="submit"]');
178
    $login_button->submit();
179
}
180
181
sub patron_opac_auth {
182
    my ( $driver,$patronusername, $patronpassword) = @_;
183
    fill_form( $driver, { userid => $patronusername, password => $patronpassword } );
184
    my $login_button = $driver->find_element('//input[@value="Log in"]');
185
    $login_button->submit();
186
}
187
188
sub fill_form {
189
    my ( $driver, $values ) = @_;
190
    while ( my ( $id, $value ) = each %$values ) {
191
        my $element = $driver->find_element('//*[@id="'.$id.'"]');
192
        my $tag = $element->get_tag_name();
193
        if ( $tag eq 'input' ) {
194
            $driver->find_element('//input[@id="'.$id.'"]')->send_keys($value);
195
        } elsif ( $tag eq 'select' ) {
196
            $driver->find_element('//select[@id="'.$id.'"]/option[@value="'.$value.'"]')->click;
197
        }
198
    }
199
}
200
201
sub cleanup {
202
    my $dbh = C4::Context->dbh;
203
    $dbh->do(q|DELETE FROM categories WHERE categorycode = ?|, {}, $sample_data->{category}{categorycode});
204
    $dbh->do(q|DELETE FROM borrowers WHERE userid = ?|, {}, $sample_data->{patron}{userid});
205
}
206
207
sub time_diff {
208
    my $lib = shift;
209
    my $now = gettimeofday;
210
    warn "CP $lib = " . sprintf("%.2f", $now - $prev_time ) . "\n";
211
    $prev_time = $now;
212
}
(-)a/t/lib/Selenium.pm (-1 / +185 lines)
Line 0 Link Here
0
- 
1
package t::lib::Selenium;
2
3
use Modern::Perl;
4
5
use Koha::Database;
6
7
use Carp;
8
use Module::Load;
9
use String::Random;
10
use Time::HiRes qw(gettimeofday);
11
use Selenium::Waiter qw/wait_until/;
12
use Try::Tiny;
13
14
my $dbh = C4::Context->dbh;
15
my $login = 'koha';
16
my $password = 'koha';
17
my $base_url= 'http://'.C4::Context->preference("staffClientBaseURL")."/cgi-bin/koha/";
18
19
sub auth {
20
    my ( $driver, $login, $password) = @_;
21
    fill_form( $driver, { userid => 'koha', password => 'koha' } );
22
    my $login_button = $driver->find_element('//input[@id="submit"]');
23
    $login_button->submit();
24
}
25
26
sub patron_auth {
27
    my ( $driver,$patronusername, $patronpassword) = @_;
28
    fill_form( $driver, { userid => $patronusername, password => $patronpassword } );
29
    my $login_button = $driver->find_element('//input[@id="submit"]');
30
    $login_button->submit();
31
}
32
33
sub patron_opac_auth {
34
    my ( $driver,$patronusername, $patronpassword) = @_;
35
    fill_form( $driver, { userid => $patronusername, password => $patronpassword } );
36
    my $login_button = $driver->find_element('//input[@value="Log in"]');
37
    $login_button->submit();
38
}
39
40
sub fill_form {
41
    my ( $driver, $values ) = @_;
42
    while ( my ( $id, $value ) = each %$values ) {
43
        my $element = $driver->find_element('//*[@id="'.$id.'"]');
44
        my $tag = $element->get_tag_name();
45
        if ( $tag eq 'input' ) {
46
             $driver->find_element('//input[@id="'.$id.'"]')->send_keys($value);
47
        } elsif ( $tag eq 'select' ) {
48
             $driver->find_element('//select[@id="'.$id.'"]/option[@value="'.$value.'"]')->click;
49
        }
50
    }
51
}
52
53
sub cleanup {
54
    my ($sample_data, $number_of_biblios_to_insert,$borrowernumber)  = @_;
55
    my $dbh = C4::Context->dbh;
56
    $dbh->do(q|DELETE FROM categories WHERE categorycode = ?|, {},     $sample_data->{category}{categorycode});
57
    $dbh->do(q|DELETE FROM borrowers WHERE userid = ?|, {}, $sample_data->{patron}{userid});
58
    for my $i ( 1 .. $number_of_biblios_to_insert ) {
59
        $dbh->do(qq|DELETE FROM biblio WHERE title = "test biblio $i"|);
60
    };
61
62
    $dbh->do(q|DELETE FROM issues where borrowernumber=?|, {}, $borrowernumber);
63
    $dbh->do(q|DELETE FROM old_issues where borrowernumber=?|, {},$borrowernumber);
64
    for my $i ( 1 .. $number_of_biblios_to_insert ) {
65
        $dbh->do(qq|DELETE items, biblio FROM biblio INNER JOIN items ON biblio.biblionumber = items.biblionumber WHERE biblio.title ="test biblio$i"|);
66
    };
67
}
68
69
sub time_diff {
70
    my ($prev_time, $lib) = (@_);
71
    my $now = gettimeofday;
72
    warn "CP $lib = " . sprintf("%.2f", $now - $prev_time ) . "\n";
73
   $prev_time = $now;
74
}
75
76
sub pause_driver {
77
    my ($driver, $element) = @_;
78
    $driver->set_implicit_wait_timeout(30000);
79
    my $elem_exists = wait_until {$driver->find_element_by_xpath('$element')};
80
81
    if ($elem_exists) {
82
      $driver->find_element_by_xpath('$element')->click;
83
    }
84
}
85
86
87
=head1 NAME
88
89
t::lib::Selenium.pm - Koha module for common Selenium functions
90
91
=head1 SYNOPSIS
92
93
94
=head1 DESCRIPTION
95
96
This Perl module
97
98
99
This module automatically creates database records for you.
100
If needed, records for foreign keys are created too.
101
Values will be randomly generated if not passed to TestBuilder.
102
Note that you should wrap these actions in a transaction yourself.
103
104
=head1 METHODS
105
106
=head2 new
107
108
    my $builder = t::lib::TestBuilder->new;
109
110
    Constructor - Returns the object TestBuilder
111
112
=head2 schema
113
114
    my $schema = $builder->schema;
115
116
    Getter - Returns the schema of DBIx::Class
117
118
=head2 delete
119
120
    $builder->delete({
121
        source => $source,
122
        records => $patron, # OR: records => [ $patron, ... ],
123
    });
124
125
    Delete individual records, created by builder.
126
    Returns the number of delete attempts, or undef.
127
128
=head2 build
129
130
    $builder->build({ source  => $source_name, value => $value });
131
132
    Create a test record in the table, represented by $source_name.
133
    The name is required and must conform to the DBIx::Class schema.
134
    Values may be specified by the optional $value hashref. Will be
135
    randomized otherwise.
136
    If needed, TestBuilder creates linked records for foreign keys.
137
    Returns the values of the new record as a hashref, or undef if
138
    the record could not be created.
139
140
    Note that build also supports recursive hash references inside the
141
    value hash for foreign key columns, like:
142
        value => {
143
            column1 => 'some_value',
144
            fk_col2 => {
145
                columnA => 'another_value',
146
            }
147
        }
148
    The hash for fk_col2 here means: create a linked record with build
149
    where columnA has this value. In case of a composite FK the hashes
150
    are merged.
151
152
    Realize that passing primary key values to build may result in undef
153
    if a record with that primary key already exists.
154
155
=head2 build_object
156
157
Given a plural Koha::Object-derived class, it creates a random element, and
158
returns the corresponding Koha::Object.
159
160
    my $patron = $builder->build_object({ class => 'Koha::Patrons' [, value => { ... }] });
161
162
=head1 AUTHOR
163
164
Alex Buckley <alexbuckley@catalyst.net.nz>
165
166
Catalyst Koha Development Team
167
168
=head1 COPYRIGHT
169
170
Copyright 2017 - Catalyst IT
171
172
=head1 LICENSE
173
174
This file is part of Koha.
175
176
Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
177
the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
178
179
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.
180
181
You should have received a copy of the GNU General Public License along with Koha; if not, see <http://www.gnu.org/licenses>.
182
183
=cut
184
185
1;

Return to bug 19359