|
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 |
} |