TT#56376 selenium: add file Common.pm

Some selenium tests depend on each other.
Example: controller_customer.t doesnt work, if controller_domain.t isnt
executed beforehand.
Common.pm is used so that selenium tests are more independent. Right now,
it contains code to create a domain.
Very useful for multithreading later on.

Change-Id: If01c7cd4d17ef66771bc64516088d3f57b02bf78
changes/22/28922/6
Nico Schedel 7 years ago
parent 0649dcb594
commit 0d1e5ead5b

@ -0,0 +1,28 @@
package Selenium::Collection::Common;
use warnings;
use strict;
use Moo;
use Test::More import => [qw(diag ok is)];
has 'driver' => (
is => 'ro'
);
sub create_domain {
my ($self, $name) = @_;
return unless $name;
diag('Go to domains page');
$self->driver->find_element('//*[@id="main-nav"]/li[5]/a')->click();
$self->driver->find_element('//*[@id="main-nav"]/li[5]/ul/li[6]/a')->click();
diag('Try to add a domain');
$self->driver->find_element('//*[@id="content"]/div/div[1]/span[2]/a')->click();
ok($self->driver->wait_for_text('//*[@id="reselleridtable"]/tbody/tr[1]/td[2]', 'default'), "Default reseller and creation site are avalible");
$self->driver->find_element('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input')->click(); #select default reseller
$self->driver->find_element('//*[@id="domain"]')->send_keys($name);
$self->driver->find_element('//*[@id="save"]')->click();
}
1;

@ -3,6 +3,7 @@ use strict;
use lib 't/lib';
use Test::More import => [qw(done_testing is ok diag like)];
use Selenium::Remote::Driver::FirefoxExtensions;
use Selenium::Collection::Common;
my $browsername = $ENV{BROWSER_NAME} || "firefox"; # possible values: firefox, htmlunit, chrome
@ -13,21 +14,15 @@ my $d = Selenium::Remote::Driver::FirefoxExtensions->new(
},
);
my $c = Selenium::Collection::Common->new(
driver => $d
);
diag('Logging in');
$d->login_ok();
diag('Go to domains page');
$d->find_element('//*[@id="main-nav"]/li[5]/a')->click();
$d->find_element('//*[@id="main-nav"]/li[5]/ul/li[6]/a')->click();
diag('Try to add a domain');
$d->find_element('//*[@id="content"]/div/div[1]/span[2]/a')->click();
ok(1, "Domain website seems to exist");
$d->find_element('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input')->click(); #select default reseller
my $domainstring = ("test" . int(rand(10000)) . ".example.org"); #create string for checking later
$d->find_element('//*[@id="domain"]')->send_keys($domainstring);
$d->find_element('//*[@id="save"]')->click();
ok(2, "Create field shows and works");
$c->create_domain($domainstring);
diag('Ensure Ajax loading has finished by searching garbage');
$d->find_element('//*[@id="Domain_table_filter"]/label/input')->send_keys('thisshouldnotexist'); #search random value

Loading…
Cancel
Save