From b62a4472b4c3f8171f679fb14f01844870c81f74 Mon Sep 17 00:00:00 2001 From: Tim Buckland Date: Sun, 4 Aug 2019 12:07:41 +0100 Subject: [PATCH] driver option in wif.config - version 1.13.1 --- CHANGES.md | 103 +++++++++++++++++++++++++++++++---------------------- MANUAL.md | 69 +++++++++++++++++++++++++++++++---- README.md | 2 +- wif.pl | 13 ++++--- 4 files changed, 133 insertions(+), 54 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8fb3b93..401713f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,77 +2,96 @@ Tim Buckland, https://github.com/Qarj/WebImblaze-Framework ---------------------------------- +--- + ## Release History: +### Version 1.13.1 - Aug 4, 2019 + +- `wif.config` now supports `driver=` to specify either `chrome` (Selenium Server) or `chromedriver` (use chromedriver directly) + ### Version 1.13.0 - Jun 24, 2019 -* `wif.config` now supports `output_location=` in the `path` section so that the WebImblaze output folder can be controlled (default is `./temp`) + +- `wif.config` now supports `output_location=` in the `path` section so that the WebImblaze output folder can be controlled (default is `./temp`) ### Version 1.12.0 - Apr 4, 2019 -* --slack-alert option to tasks file, e.g. `tasks/Examples.pl` will alert to Slack on failure + +- --slack-alert option to tasks file, e.g. `tasks/Examples.pl` will alert to Slack on failure ### Version 1.11 - Apr 1, 2019 -* option to show the batch url -* ability to locate a test file from cwd assuming wif.pl started from another folder (e.g. system path) + +- option to show the batch url +- ability to locate a test file from cwd assuming wif.pl started from another folder (e.g. system path) ### Version 1.10 - Nov 12, 2018 -* improved Linux support -* remove BrowserMob Proxy support + +- improved Linux support +- remove BrowserMob Proxy support ### Version 1.09 - Oct 31, 2018 -* rename project to WebImblaze-Framework -* added --selenium-port, --selenium-post switches -* added --headless switch -* added --keep-session and --resume-session -* grey out superseded automation results -* added Notepad++ and Ultraedit syntax highlighting files +- rename project to WebImblaze-Framework +- added --selenium-port, --selenium-post switches +- added --headless switch +- added --keep-session and --resume-session +- grey out superseded automation results +- added Notepad++ and Ultraedit syntax highlighting files ### Version 1.08 - Jun 8, 2017 -* optimisations - create less temporary files -* exit 1 if webinject.pl exits 1 -* example wif.config removed from project, but wif.pl can now create a default one if missing -* example on how to alert in Slack channel if regression batch fails -* moved some functionality to webinject.pl for performance reasons -* alert if user account does not have appropriate write permissions + +- optimisations - create less temporary files +- exit 1 if webinject.pl exits 1 +- example wif.config removed from project, but wif.pl can now create a default one if missing +- example on how to alert in Slack channel if regression batch fails +- moved some functionality to webinject.pl for performance reasons +- alert if user account does not have appropriate write permissions ### Version 1.05 - Jun 12, 2016 -* testonly and liveonly was replaced by runon in webinject, wif.pl needs to write out the environment to the webinject config to support this -* selenium server location was using a hard coded value rather than the config value + +- testonly and liveonly was replaced by runon in webinject, wif.pl needs to write out the environment to the webinject config to support this +- selenium server location was using a hard coded value rather than the config value ### Version 1.04 - May 30, 2016 -* webinject.pl no longer requires less than character to be escaped, needed to update wif.pl as a result -* made many of the results output internal links relative + +- webinject.pl no longer requires less than character to be escaped, needed to update wif.pl as a result +- made many of the results output internal links relative ### Version 1.03 - May 11, 2016 -* automatically switch environment if target not found but can be found an another environment + +- automatically switch environment if target not found but can be found an another environment ### Version 1.02 - May 11, 2016 -* no longer have to cd to wif.pl folder before starting it -* use make_path to make folders, will not die if folder already exists -* fixed write batch summary record retry -* fixed a rare bug with processing the environment config + +- no longer have to cd to wif.pl folder before starting it +- use make_path to make folders, will not die if folder already exists +- fixed write batch summary record retry +- fixed a rare bug with processing the environment config ### Version 1.01 - May 4, 2016 -* find test case file when folder not specified, and also without xml extension -* command line options now accepted for tasks --target and --batch -* tweaks to robustness with many parallel instances of wif.pl + +- find test case file when folder not specified, and also without xml extension +- command line options now accepted for tasks --target and --batch +- tweaks to robustness with many parallel instances of wif.pl ### Version 1.00 - May 2, 2016 -* fixed a bug with file unlocking -* STDOUT and STDERR for wif.pl and webinject.pl can be captured and linked to from the results -* workaround for Selenium server port -* auto creates temp/ folder if needed -* tasks like Regression.pl do not need config files any more + +- fixed a bug with file unlocking +- STDOUT and STDERR for wif.pl and webinject.pl can be captured and linked to from the results +- workaround for Selenium server port +- auto creates temp/ folder if needed +- tasks like Regression.pl do not need config files any more ### Version 0.03 - Apr 25, 2016 -* improved file locking logic -* improved css styles -* introduced an option to capture STDOUT for both wif.pl and webinject.pl -* introduced Runner.pm can now run tests "in process" as well as starting a new process for each test + +- improved file locking logic +- improved css styles +- introduced an option to capture STDOUT for both wif.pl and webinject.pl +- introduced Runner.pm can now run tests "in process" as well as starting a new process for each test ### Version 0.02 - Apr 23, 2016 -* first release - fully functional WebInject Framework designed to organise WebInject configuration and test run results + +- first release - fully functional WebInject Framework designed to organise WebInject configuration and test run results ### Version 0.01 - Jan 31, 2016 -* project created + +- project created diff --git a/MANUAL.md b/MANUAL.md index 1a582fe..8677954 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -1,4 +1,4 @@ -# WebImblaze Framework 1.13.0 Manual +# WebImblaze Framework 1.13.1 Manual # wif.config @@ -14,6 +14,7 @@ The `wif.config` file is also used by wif.pl to store some of the command line o invoked wif.pl. The next time you run wif.pl, it will use those options as a default. An example `wif.config` looks like this: + ``` [main] batch=example_batch @@ -24,6 +25,7 @@ target=team1 [path] selenium_location_full=C:\selenium\selenium-server-3-standalone.jar chromedriver_location_full=C:\selenium\chromedriver.exe +driver=chromedriver testfile_full=../WebImblaze/examples/get.test web_server_address=localhost web_server_location_full=C:\Apache24\htdocs @@ -34,12 +36,15 @@ output_location=./temp/ ## [main] config ### batch + The batch name to group run results under. Updated by `wif.pl --batch` option. ### environment + The high level environment name, e.g. DEV, PAT or PROD. Updated by `wif.pl --env` option. ### is_automation_controller + `true` if this machine is a company automated testing controller, `false` otherwise. `true` means that WebImblaze `automationcontrolleronly` test steps will be run. Otherwise they @@ -50,6 +55,7 @@ This feature gives you a way of developing and running your tests on a workstati that are not possible to run from your local environment. ### target + Target 'mini-environment' for the test case file. Update by wif.pl --target option. For example, the mini environment might be the name of a team within your development environment. @@ -57,12 +63,21 @@ For example, the mini environment might be the name of a team within your develo ## [path] config ### chromedriver_location_full + Where to find the chromedriver binary. If you do not have Selenium tests, this value does not matter. ``` chromedriver_location_full=C:\selenium\chromedriver.exe ``` +### driver + +Browser driver to use, current choices are `chrome` (i.e. Selenium Server) or `chromeDriver` (Selenium Server or Java not needed). + +``` +driver=chromedriver +``` + ### output_location Where `wi.pl` should output to. @@ -72,6 +87,7 @@ output_location=./temp/ ``` ### selenium_location_full + Where to find the Selenium Standalone Server JAR file. If you are not using Selenium WebDriver it is safe to leave this option at the default, even if is not installed. ``` @@ -79,6 +95,7 @@ selenium_location_full=C:\selenium\selenium-server-standalone-2.53.1.jar ``` ### testfile_full + The last test case file that was run. Updated by wif.pl. ``` @@ -133,12 +150,12 @@ sub-environments as you need. Only `_global.config` cannot be renamed. +## Level 1: environment_config/\_global.config -## Level 1: environment_config/_global.config +\_global.config contains configuration common to all environments. -_global.config contains configuration common to all environments. +\_global.config example: -_global.config example: ``` [autoassertions] autoassertion1=^((?!HTTP Error 404.0 . Not Found).)*$|||Page not found error @@ -168,6 +185,7 @@ stop_refresh=HTTP-EQUIV="REFRESH"|||"HTTP-EQUIV=___WIF___" All other .config files directly in this folder refer to high level environment names. In the provided example, three environments have been defined: + - DEV - development - PAT - production acceptance test - PROD - production @@ -175,6 +193,7 @@ In the provided example, three environments have been defined: For wif.pl quick start purposes, you can leave this as it is. DEV.config example: + ``` [main] testonly=true @@ -202,6 +221,7 @@ Note that for any configuration item provided at a lower level, it will take pre over the same configuration specified at a higher level. Level 3 config example (e.g. DEV/skynet.config): + ``` [main] ntlm=.skynet.com:8020::SKYNET\JXS-SCT001:password @@ -221,9 +241,11 @@ autoassertion5=^((?!Java Stacktrace Error).)*$|||Java Abend ## Sections within the configuration files ### [main] + Refer to the WebImblaze Manual, Configuration section. In this section you can specify values for: + - useragent - httpauth - baseurl, baseurl1, baserurl2 @@ -236,22 +258,26 @@ In this section you can specify values for: Important - if you do not want to set a value, it is better to delete the value rather than set it as blank. Otherwise WebImblaze may try to use a null value and fail. ### [userdefined] + Refer to the WebImblaze Manual, Configuration section. In a nutshell, you can make up your own configuration items. So if you had `google=www.google.co.uk` you could refer to it in the WebImblaze tests as `{GOOGLE}`. ### [autoassertions] and [smartassertions] + Refer to the WebImblaze Manual, Configuration section. There examples in the example config - you can just delete them if you do not want them. ### [baseurl_subs] + WebImblaze creates an html file for every step result. WebImblaze will remap the http references in the html source back to the web server under test using the page baseurl. Sometimes you may want to tweak the urls - for example, change https references to http to get around test environment ssl certificate issues. Here is an example substitution: + ``` https_to_http_remap=https:(.+):8080|||"http:".$1.":4040" ``` @@ -260,6 +286,7 @@ On the LHS of the three bars, we have the LHS of the regex. On the RHS we have t in the form of a Perl expression. ### [content_subs] + To change the step html response content, you can specify regular expressions in this section. They work in the same way as described in [baseurl_subs]. @@ -267,13 +294,14 @@ Why would you want to do this? Some pages will try to redirect to somewhere else desirable since we want to see the actual result. So we do a substitution to break the redirect. Here is a very common example: + ``` stop_refresh=HTTP-EQUIV="REFRESH"|||"HTTP-EQUIV=___WIF___" ``` -## DEV, PAT, PROD/_alias.config +## DEV, PAT, PROD/\_alias.config -In each of the example environment config folders, there is an example _alias.config file containing +In each of the example environment config folders, there is an example \_alias.config file containing alternate names for the 'mini-environments'. It is possible to set up as many you want, so long as the value on the right hand side matches @@ -282,18 +310,21 @@ a .config file in the same folder. # wif.pl command line options Typical example: + ``` wif.pl example_test --env DEV --target team1 --batch My_Tests ``` The WebImblaze-Framework will search all sub folders of tests/ for a file called `example_test.xml`. If it doesn't find it, it will also search (plus subfolders): + ``` ../WebImblaze ../WebImblaze-Selenium ``` To run the same test again, just issue: + ``` wif.pl ``` @@ -303,51 +334,65 @@ wif.pl ## `wif.pl --help` ## `wif.pl tests/mytest.xml` + Runs the tests in mytest.xml. ## `wif.pl mytest` + Will search sub folders of ./ for mytest.xml and will run the first one found. ## `wif.pl --target my_team` + Sets the 'mini-environment' to `my_team` and runs the last test with the saved options. ## `wif.pl --batch Priority_1_Tests` + Sets the batch to `Priority_1_Tests` and runs the last test with the saved options. ## `wif.pl --env PROD` + Sets the environment to PROD and runs the last test with the saved options. ## `--selenium-host` + Passes the Selenium (Grid) host to `wi.pl`. ## `--selenium-port` + Passes the Selenium (Grid) port to `wi.pl`. ## `--headless` + Tells `wi.pl` to run Selenium Chrome tests in headless mode. ## `--no-retry` + Tells WebImblaze to ignore the `retry` and `retryfromstep` parameters. ## `--no-update-config` + Tells wif.pl not to update wif.config with the current options. Important for running many tests in parallel - otherwise competing instances of wif.pl will try to update the wif.config file at the same time - and cause unknown problems. ## `--capture-stdout` + When running through the command line, you'll see wi.pl and wif.pl go straight to the command prompt. However when running a large set of tests from a service account, you will want the STDOUT output to be captured. ## `--keep` + Tells wif.pl not to delete the temporary folder it created for WebImblaze's temporary files. For debug purposes. ## `--keep-session` + Passes this option to `wi.pl` which tells it to remember the Selenium session information and not close Selenium and the browser at the end of the run. ## `--resume-session` + If `--keep-session` was used in the previous run, then `wi.pl` will attempt to connect to the existing Selenium session and browser and run the tests from the existing state. @@ -355,9 +400,11 @@ This is useful for debugging very long workflows where there is a problem deep i not want to run the entire workflow to try various ideas to get your test step working. ## `--create-config` + Creates (or overwrites) the wif.config with default values to get you started. # tasks/ folder + The tasks folder contains a script called `Examples.pl` that runs all of the WebImblaze examples at the same time. If you "start" a test, a new process will be created to run that test. This enables you to run many tests in @@ -403,18 +450,23 @@ Runner::start('../tests/regression/profile.xml'); ``` Then if you ran it with the `--group` parameter: + ``` tasks\myRegression.pl --group Bear ``` + It would run: + - `register.xml` - since there is a matching group - `purchase.xml` - ditto -- `profile.xml` - since no groups are specified, default - run it +- `profile.xml` - since no groups are specified, default - run it Another example: + ``` tasks\myRegression.pl --group Frog ``` + Would run `register.xml` and `profile.xml` but not `purchase.xml`. And if you do not specify the --group option at all, then all test files would be run. @@ -432,12 +484,14 @@ certain that you are using the right keyword / parameter. _If you've done this previously and are updating - delete the existing WebImblaze language first._ It is worth spending two minutes to set up WebImblaze syntax highlighting in Notepad++ + - Select menu `Language -> Define your language ...` - Click `Import...` - Select file `WebImblaze-Framework/tools/webimblaze_notepad++.xml` - Restart Notepad++ It looks much, much better if you use a dark theme. + - Select menu `Settings -> Style Configurator...` - Set `Select theme :` to `Plastic Code Wrap` - Check `Enable global background colour` @@ -451,6 +505,7 @@ Note that Material-Dark is a nice theme: https://github.com/naderi/material-them The script `tools/transmute.pl` will output an xml test file in the new format. Example usage (assuming you have `transmute.pl` in path): + ``` transmute.pl MyTest.xml > MyTest.test ``` diff --git a/README.md b/README.md index 245aa13..a1bc6c4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# WebImblaze-Framework 1.13.0 +# WebImblaze-Framework 1.13.1 Automated regression testing framework for diff --git a/wif.pl b/wif.pl index c807941..0254c74 100644 --- a/wif.pl +++ b/wif.pl @@ -11,7 +11,7 @@ use warnings; use vars qw/ $VERSION /; -$VERSION = '1.13.0'; +$VERSION = '1.13.1'; # WebImblaze-Framework is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -57,12 +57,14 @@ my $DEFAULT_OUTPUT_LOCATION = './temp/'; my $DEFAULT_WEBIMBLAZE_LOCATION = '../WebImblaze'; +my $LEGACY_DEFAULT_DRIVER = 'chrome'; +my $DEFAULT_DRIVER = 'chromedriver'; # start globally read/write variables declaration - only variables declared here will be read/written directly from subs my ( $opt_version, $opt_target, $opt_batch, $opt_environment, $opt_selenium_host, $opt_selenium_port, $opt_headless, $opt_no_retry, $opt_help, $opt_keep, $opt_keep_session, $opt_resume_session, $opt_capture_stdout, $opt_no_update_config, $opt_show_batch_url); my ( $testfile_full, $testfile_name, $testfile_path, $testfile_parent_folder_name ); my ( $config_is_automation_controller ); -my ( $web_server_location_full, $web_server_address, $selenium_location_full, $chromedriver_location_full, $webimblaze_location, $output_location ); +my ( $web_server_location_full, $web_server_address, $selenium_location_full, $driver, $chromedriver_location_full, $webimblaze_location, $output_location ); my ( $temp_folder_name ); my $config = Config::Tiny->new; my $target_config = Config::Tiny->new; @@ -202,9 +204,8 @@ sub call_webimblaze_with_testfile { push @_args, '--resume-session'; } - # for now we hard code the browser to Chrome push @_args, '--driver'; - push @_args, 'chrome'; + push @_args, $driver; # WebImblaze test cases expect the current working directory to be where wi.pl is my $_orig_cwd = cwd; @@ -1222,6 +1223,7 @@ sub _create_default_config { $_config .= q{}."\n"; $_config .= '[path]'."\n"; $_config .= $_selenium_location_full; + $_config .= "driver=$DEFAULT_DRIVER\n"; $_config .= $_chromedriver_location_full; $_config .= 'testfile_full=../WebImblaze/examples/get.xml'."\n"; $_config .= 'web_server_address=localhost'."\n"; @@ -1262,6 +1264,7 @@ sub _read_config { # path $testfile_full = $config->{path}->{testfile_full}; $selenium_location_full = $config->{path}->{selenium_location_full}; + $driver = $config->{path}->{driver}; $chromedriver_location_full = $config->{path}->{chromedriver_location_full}; $web_server_location_full = $config->{path}->{web_server_location_full}; $web_server_address = $config->{path}->{web_server_address}; @@ -1270,6 +1273,7 @@ sub _read_config { $webimblaze_location //= $DEFAULT_WEBIMBLAZE_LOCATION; $output_location //= $DEFAULT_OUTPUT_LOCATION; + $driver //= $LEGACY_DEFAULT_DRIVER; # normalise config if (lc $config_is_automation_controller eq 'true' ) { @@ -1293,6 +1297,7 @@ sub _write_config { # path $config->{path}->{testfile_full} = $testfile_full; $config->{path}->{selenium_location_full} = $selenium_location_full; + $config->{path}->{driver} = $driver; $config->{path}->{chromedriver_location_full} = $chromedriver_location_full; $config->{path}->{web_server_location_full} = $web_server_location_full; $config->{path}->{web_server_address} = $web_server_address;