From 775b5b80d0fe453dd2def25ec43011af4e3abf0e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 18 Sep 2017 15:58:15 -0300 Subject: [PATCH] Bug 19337: Make basic_workflow.t configurable through ENV This patch makes the basic_workflow.t selenium tests read ENV for the following vars: KOHA_USER KOHA_PASS KOHA_INTRANET_URL SELENIUM_ADDR SELENIUM_PORT to properly configure the running environment. If absent, all variables fallback to current behaviour: KOHA_USER // 'koha' KOHA_PASS // 'koha' KOHA_INTRANET_URL (unchanged) SELENIUM_ADDR // 'localhost' SELENIUM_PORT // 4444 [*] Selenium defaults are documented on the Selenium::Remote::Driver docs. Prerequisites: Make sure you have a working environment for the Selenium tests: - Run: $ sudo apt update $ sudo apt install xvfb firefox-esr To test: - Run: $ sudo koha-shell kohadev k$ cd kohaclone k$ wget https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar \ -O /tmp/selenium.jar k$ SELENIUM_PATH=/tmp/selenium.jar k$ Xvfb :1 -screen 0 1024x768x24 2>&1 >/dev/null & k$ DISPLAY=:1 java -jar $SELENIUM_PATH & k$ prove t/db_dependent/selenium/basic_workflow.t => SUCCESS: Tests pass - Apply this patch - Run: k$ prove t/db_dependent/selenium/basic_workflow.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart Signed-off-by: Jonathan Druart (cherry picked from commit 5bb19808bb23a01a257a0970bd7e2ae43fb5b3d6) Signed-off-by: Fridolin Somers (cherry picked from commit f2b53042bd94ae4427ad08f5c55944974458ded4) Signed-off-by: Katrin Fischer --- t/db_dependent/selenium/basic_workflow.t | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/t/db_dependent/selenium/basic_workflow.t b/t/db_dependent/selenium/basic_workflow.t index 0147624c11..b50fdebb06 100644 --- a/t/db_dependent/selenium/basic_workflow.t +++ b/t/db_dependent/selenium/basic_workflow.t @@ -42,10 +42,15 @@ use Test::More tests => 20; use MARC::Record; use MARC::Field; -my $dbh = C4::Context->dbh; -my $login = 'koha'; -my $password = 'koha'; -my $base_url= ( $ENV{KOHA_INTRANET_URL} || 'http://'.C4::Context->preference("staffClientBaseURL") ) . "/cgi-bin/koha/"; +my $dbh = C4::Context->dbh; +my $login = $ENV{KOHA_USER} || 'koha'; +my $password = $ENV{KOHA_PASS} || 'koha'; +my $base_url + = ( $ENV{KOHA_INTRANET_URL} || 'http://' . C4::Context->preference("staffClientBaseURL") ) + . "/cgi-bin/koha/"; +my $selenium_addr = $ENV{SELENIUM_ADDR} || 'localhost'; +my $selenium_port = $ENV{SELENIUM_PORT} || 4444; + my $number_of_biblios_to_insert = 3; @@ -89,7 +94,11 @@ SKIP: { open my $fh, '>>', '/tmp/output.txt'; - my $driver = Selenium::Remote::Driver->new; + my $driver = Selenium::Remote::Driver->new( + port => $selenium_port, + remote_server_addr => $selenium_addr + ); + $start = gettimeofday; $prev_time = $start; $driver->get($base_url."mainpage.pl"); @@ -202,7 +211,7 @@ END { sub auth { my ( $driver, $login, $password) = @_; - fill_form( $driver, { userid => 'koha', password => 'koha' } ); + fill_form( $driver, { userid => $login, password => $password } ); my $login_button = $driver->find_element('//input[@id="submit"]'); $login_button->submit(); } -- 2.39.5