TT#56376 selenium: move login_ok() to Collection.pm

Moving function login_ok() from FirefoxExtensions.pm to Collection.pm.
FirefoxExtensions.pm should be used to store functions which make
programming stuff easier.
Common.pm should be used to store commonly used selenium routines.
Edited all files accordingly to work with this change.

Change-Id: I00ece7de88f7677665c5b8b87ce1e60be9c5854d
changes/79/29479/7
Nico Schedel 6 years ago
parent c06d05602d
commit e7a0927f0f

@ -10,6 +10,25 @@ has 'driver' => (
is => 'ro'
);
sub login_ok {
my ($self) = @_;
diag("Loading login page (logout first)");
my $uri = $ENV{CATALYST_SERVER} || 'http://localhost:3000';
$self->driver->get("$uri/logout"); # make sure we are logged out
$self->driver->get("$uri/login");
diag("Do Admin Login");
ok($self->driver->find_text("Admin Sign In"), "Text Admin Sign In found");
is($self->driver->get_title, '', 'No Tab Title was set');
$self->driver->find_element('#username', 'css')->send_keys('administrator');
$self->driver->find_element('#password', 'css')->send_keys('administrator');
$self->driver->find_element('#submit', 'css')->click();
diag("Checking Admin interface");
is($self->driver->get_title, 'Dashboard', 'Tab Title is correct');
is($self->driver->find_element('//*[@id="masthead"]//h2')->get_text(), "Dashboard", 'We are in the Dashboard. Login Successful');
}
sub create_domain {
my ($self, $name, $reseller) = @_;
return unless $name;

@ -33,25 +33,6 @@ sub BUILD {
$self->set_timeout("implicit", 10_000);
}
sub login_ok {
my ($self) = @_;
diag("Loading login page (logout first)");
my $uri = $ENV{CATALYST_SERVER} || 'http://localhost:3000';
$self->get("$uri/logout"); # make sure we are logged out
$self->get("$uri/login");
diag("Do Admin Login");
ok($self->find_text("Admin Sign In"), "Text Admin Sign In found");
is($self->get_title, '', 'No Tab Title was set');
$self->find_element('#username', 'css')->send_keys('administrator');
$self->find_element('#password', 'css')->send_keys('administrator');
$self->find_element('#submit', 'css')->click();
diag("Checking Admin interface");
is($self->get_title, 'Dashboard', 'Tab Title is correct');
is($self->find_element('//*[@id="masthead"]//h2')->get_text(), "Dashboard", 'We are in the Dashboard. Login Successfull');
}
sub find_text {
try {
my ($self, $text, $scheme) = @_;

@ -4,6 +4,7 @@ use strict;
use lib 't/lib';
use Test::More import => [qw(done_testing is diag ok)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
my $browsername = $ENV{BROWSER_NAME} || "firefox"; # possible values: firefox, htmlunit, chrome
@ -14,9 +15,13 @@ my $d = Selenium::Remote::Driver::FirefoxExtensions->new(
},
);
my $c = Selenium::Collection::Common->new(
driver => $d
);
ok(1, "Instantiation ok");
$d->login_ok();
$c->login_ok();
diag("Done: admin-login.t");
done_testing;

@ -4,6 +4,7 @@ use strict;
use lib 't/lib';
use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
my $browsername = $ENV{BROWSER_NAME} || "firefox"; # possible values: firefox, htmlunit, chrome
@ -14,7 +15,11 @@ my $d = Selenium::Remote::Driver::FirefoxExtensions->new(
},
);
$d->login_ok();
my $c = Selenium::Collection::Common->new(
driver => $d
);
$c->login_ok();
my $billingname = ("testprofile" . int(rand(10000))); #create string for checking later
diag("Go to Billing page");

@ -27,7 +27,8 @@ if(!$pbx){
} else {
print "---PBX check is ENABLED---\n";
};
$d->login_ok();
$c->login_ok();
my $domainstring = ("test" . int(rand(10000)) . ".example.org"); #create string for checking later
$c->create_domain($domainstring);

@ -19,7 +19,7 @@ my $c = Selenium::Collection::Common->new(
);
diag('Logging in');
$d->login_ok();
$c->login_ok();
my $domainstring = ("test" . int(rand(10000)) . ".example.org"); #create string for checking later
$c->create_domain($domainstring);

@ -4,6 +4,7 @@ use strict;
use lib 't/lib';
use Test::More import => [qw(done_testing is ok diag todo_skip)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
my $browsername = $ENV{BROWSER_NAME} || "firefox"; # possible values: firefox, htmlunit, chrome
@ -14,7 +15,11 @@ my $d = Selenium::Remote::Driver::FirefoxExtensions->new(
},
);
$d->login_ok();
my $c = Selenium::Collection::Common->new(
driver => $d
);
$c->login_ok();
my $groupname = ("testinggroup" . int(rand(10000))); #create string for checking later

@ -19,7 +19,7 @@ my $c = Selenium::Collection::Common->new(
driver => $d
);
$d->login_ok();
$c->login_ok();
my $resellername = ("test" . int(rand(10000)));
my $contractid = ("test" . int(rand(10000)));

@ -19,7 +19,7 @@ my $c = Selenium::Collection::Common->new(
driver => $d
);
$d->login_ok();
$c->login_ok();
my $resellername = ("test" . int(rand(10000)));
my $contractid = ("test" . int(rand(10000)));

Loading…
Cancel
Save