1
1
mirror of https://github.com/aelve/guide.git synced 2024-11-25 07:52:52 +03:00
5 Selenium tests
Jens Krause edited this page 2017-10-08 18:20:05 +02:00

Running tests

Setting up Selenium with the Chromium webdriver:

Instructions assume Ubuntu 16.04/16.10, but package managers for your distribution should have working distributions.

  1. Java runtime (java).

    The Oracle JVM can be installed with:

    Note: These instructions are incomplete if using OpenJDK.

    apt install oracle-java8-installer
    
  2. Selenium stand-alone server.

    Obtain the standalone server from the Selenium downloads page.

    Using the current download link (as of Oct 8. 2017) to download it to your home directory:

    wget https://goo.gl/21wWg8 -o ~/selenium-server-standalone.jar
    
  3. Chromium webdriver.

    This will install the chromedriver binary to /usr/lib/chromium-browser/chromedriver on Ubuntu. Take note of the location of the binary if your package manager uses.

    apt install chromium-chromedriver
    
  4. (Optional) For headless operation, xvfb.

    The X virtual framebuffer will allow Chromium to run for tests on a server, this is not necessary if using a desktop with X or X forwarding.

    apt install xvfb
    
  5. Launching Selenium.

    The path to the chromedriver binary needs to be given when launching the server, as follows:

    java -Dwebdriver.chrome.driver=/usr/lib/chromium-browser/chromedriver -jar ~/selenium-server-standalone.jar
    

With Stack

Before running the test suite, you will need to launch Selenium and the server will run during tests.

To run the full testsuite, do stack test. You'll need Selenium server running.

From GHCi

The tests are in the tests/ folder; you can load tests/WebSpec.hs and then execute tests. If you want to run only a subset of tests, use run (e.g. run categoryTests runs category tests).

If you get errors about unloaded packages when trying to load tests into REPL in Emacs, do M-x haskell-session-change-target guide:tests.