From 35aa975455f1cc32ca6768e279278893c85643bd Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Mon, 7 Sep 2015 18:16:11 +0300 Subject: [PATCH] Bug 14536 - PageObject squashable --- t/lib/Page/Intra.pm | 20 ++++++++++++++++++++ t/lib/Page/Opac.pm | 21 ++++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/t/lib/Page/Intra.pm b/t/lib/Page/Intra.pm index 79636f3..5f472d3 100644 --- a/t/lib/Page/Intra.pm +++ b/t/lib/Page/Intra.pm @@ -179,6 +179,26 @@ sub doPasswordLogin { return $self; #After a succesfull password login, we are directed to the same page we tried to access. } +sub failPasswordLogin { + my ($self, $username, $password) = @_; + my $d = $self->getDriver(); + $self->debugTakeSessionSnapshot(); + + my ($submitButton, $useridInput, $passwordInput) = $self->_getPasswordLoginElements(); + $useridInput->send_keys($username); + $passwordInput->send_keys($password); + $submitButton->click(); + $self->debugTakeSessionSnapshot(); + + my $cookies = $d->get_all_cookies(); + my @cgisessid = grep {$_->{name} eq 'CGISESSID'} @$cookies; + + ok($d->get_title() =~ /Log in to Koha/ #Still in the login page + , "Intra PasswordLogin failed"); + + return $self; #After a successful password login, we are directed to the same page we tried to access. +} + sub doPasswordLogout { my ($self, $username, $password) = @_; my $d = $self->getDriver(); diff --git a/t/lib/Page/Opac.pm b/t/lib/Page/Opac.pm index b7d805d..2635cb8 100644 --- a/t/lib/Page/Opac.pm +++ b/t/lib/Page/Opac.pm @@ -160,6 +160,23 @@ sub doPasswordLogin { return $self; #After a succesfull password login, we are directed to the same page we tried to access. } +sub failPasswordLogin { + my ($self, $username, $password) = @_; + my $d = $self->getDriver(); + $self->debugTakeSessionSnapshot(); + + my ($submitButton, $useridInput, $passwordInput) = $self->_getPasswordLoginElements(); + $useridInput->send_keys($username); + $passwordInput->send_keys($password); + $submitButton->click(); + $self->debugTakeSessionSnapshot(); + + ok($d->get_title() =~ /Log in to your account/ #Still in the login page + , "Opac PasswordLogin failed"); + + return $self; #After a successful password login, we are directed to the same page we tried to access. +} + sub doPasswordLogout { my ($self, $username, $password) = @_; my $d = $self->getDriver(); @@ -172,11 +189,9 @@ sub doPasswordLogout { $self->debugTakeSessionSnapshot(); $headerElements = $self->_getHeaderRegionActionElements(); #Take the changed header elements - my $txt = $headerElements->{login}->get_text(); ok(($headerElements->{login}->get_text() =~ /Log in/ || $d->get_title() =~ /Log in to your account/), "Opac Header PasswordLogout succeeded"); - return t::lib::Page::Opac::OpacMain->rebrandFromPageObject($self); - ok((), "PasswordLogout succeeded"); + return t::lib::Page::Opac::OpacMain->rebrandFromPageObject($self); } -- 1.9.1