Skip to content

Automated tests: Selenium

michaelkain edited this page Mar 29, 2019 · 1 revision

Pull two docker images:

docker pull selenium/standalone-firefox  
docker pull selenium/standalone-chrome 

Then launch one of them inside shanoir_ng_network (both of them use port 4444 so stick to one at the time):

docker run --name selenium-firefox --network=shanoir_ng_network --privileged --restart=always -p 4444:4444 -d selenium/standalone-firefox

or

docker run --name selenium-chrome --network=shanoir-ng_shanoir_ng_network --privileged --restart=always -p 4444:4444 -d selenium/standalone-chrome

You can acces Selenium hub on http://localhost:4444/wd/hub

Launch tests:

pip install selenium
  • Copy(=pull) python files that are in shanoir-ng-tests/tests
  • If you want to launch tests locally, you will need to download chrome webdriver and/or ie webdriver and copy it to tests repository. Doocker image already has it.
  • Latest versions of Firefox (47+) require Desired Capabilites of marionnette to be true. This is done for docker images, for local testing, check the code for:
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities  
dc = DesiredCapabilities.FIREFOX   
dc['marionette'] = True  
driver = webdriver.Firefox(desired_capabilities=dc)
  • Two configurations are possible:
    • Remote (in docker, headless) :
      • with --remote flag
      • -a (--address) must be http://shanoir-ng-nginx
      • -b for browser: firefox or chrome
      • -u username
      • -p password
      • example:
      python shanoir_ng_users.py --remote -b firefox -a http://shanoir-ng-nginx -u mylogin -p mypassword
    • Locally :
      • -a (--address) for example http://localhost
      • -b for browser: firefox, chrome or ie etc
      • -u username
      • -p password
      • example:
      python shanoir_ng_users.py -b firefox -a http://localhost -u mylogin -p mypassword

Selenium/marionette/firefox bugs:

Clone this wiki locally