Working in Command Line

Single page test

In order to perform a single page test you can use the command check. Take a look at the following example

galen check homepage.gspec --url "http://example.com" --size "640x480" --javascript "some.js" --include "mobile,all" --exclude "toexclude" --htmlreport "htmlreport-dir" --testngreport "testng-report.xml" --jsonreport "jsonreport-dir" --junitreport "junit-report.xml" --config "path/to/galen.config"

Command line arguments:

  • url - a URL of page for Galen to test on
  • javascript - a path for javascript file which Galen will inject in web page
  • include - a comma separated list of tags for spec sections which will be included in testing
  • exclude - a comma separated list of tags for spec sections to be excluded from the filtered group
  • size - dimensions of browser window. Consists of two numbers separated by “x” symbol
  • htmlreport - path to folder in which Galen should generate HTML reports
  • testngreport - path to xml file in which Galen should write TestNG report
  • jsonreport - path to folder in which Galen should generate JSON reports
  • junitreport - path to junit xml report file
  • config - path to config file

Running test suites

If you want to execute Galen Test Suites then you should use the following command

galen test mytest01.test --htmlreport "htmlreport-dir" --testngreport "report/testng.xml" --jsonreport "jsonreport-dir" --junitreport "junit-report.xml" --parallel-tests 4 --config "path/to/galen.config"

Command line arguments:

  • htmlreport - path to folder in which Galen should generate HTML reports
  • testngreport - path to xml file in which Galen should write TestNG report
  • junitreport - path to junit xml report file
  • parallel-tests - amount of threads for running tests in parallel
  • recursive - flag which is used in case you want to search for all .test files recursively in folder
  • filter - a filter for a test name
  • config - path to config file

Running test suites with test filter

Lets say you have multiple tests for multiple devices but you only want to execute a test for a home page. You can use ‘*’ symbol in filter

galen test mytest01.test --htmlreport "htmlreport-dir" --testngreport "report/testng.xml" --junitreport "junit-report.xml" --parallel-tests 4 --filter "Home page on * device"

Running test groups

In case you want to run tests only for specific groups you can use groups argument in command line.

galen test tests/ --htmlreport report --groups homepage,loginpage

You have to define your own groups that you use in your tests. If you use standard test suite then you can read about groups in this article

In case you use JavaScript tests then this article can help you.

Running tests with excluded groups

Sometimes you might need to run all tests that don’t belong to certain group. For this reason you can use excluded-groups argument.

galen test tests/ --htmlreport report --excluded-groups homepage,loginpage

Providing system properties

Sometimes you might need to provide system properties for your tests. For instance if you want to run tests in local Chrome, IE or PhantomJS browser – you have to provide a path to each browser or a special driver binary. This could be done with system properties. Just use -D prefix for command line argument. Here is an example how to run tests for phantomjs. In your case the path to phantomjs binary might be different:

galen test mytest01.test -Dphantomjs.binary.path=/opt/phantomjs/bin/phantomjs

Or for example if you need to run your tests in Chrome

galen test mytest01.test -Dwebdriver.chrome.driver=/opt/chromedriver/chromedriver

Creating page dump

Since version 1.3 Galen has a feature of creating a page dump. With a page dump you can store information about all your test objects on the page together with image samples.

galen dump "specs/homepage.gspec" --url "http://galenframework.com" --size "1024x768" --export "dumps/homepage-dump" --max-width "200" --max-height "200"

Command line arguments:

  • url - a URL of a web page for which you want to create a page dump
  • size - a browser window size
  • export - a path to page dump folder
  • max-width - a maximum width of an element for which it should create an image sample
  • max-height - a maximum height of an element for which it should create an image sample

Once the page dump is finished Galen will create a folder with specified path and will put all image samples in objects folder. It also provides a page.html file in which you can see all your page objects and see different spec suggestions for them.

Usage in Node-Projects

You can directly use Galen in your node project. Just use a package.json like this:

"scripts": { "galen": "galen" }, ... "devDependencies": { "galenframework-cli": "2.3.2" }

Then you can run one spec like this:

npm run galen -- check test/specs/google_success1.gspec --url 'https://www.google.com' --size '1280x800' --htmlreport dist/galen-report

Comments

We are moving all the discussions to Google Groups. From this moment, if you have problems with your test code or some issues with installation, please ask your questions in https://groups.google.com/forum/#!forum/galen-framework. This way more people will be able to help you.

comments powered by Disqus