blob: 352c4fe3e9757257bf461119a9c4019e1a2b3930 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001# Running Toaster's browser-based test suite
2
3These tests require Selenium to be installed in your Python environment.
4
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005The simplest way to install this is via pip3:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05006
Brad Bishop6e60e8b2018-02-01 10:27:11 -05007 pip3 install selenium==2.53.2
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05008
Patrick Williamsc0f7c042017-02-23 20:41:17 -06009Note that if you use other versions of Selenium, some of the tests (such as
10tests.browser.test_js_unit_tests.TestJsUnitTests) may fail, as these rely on
11a Selenium test report with a version-specific format.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050012
13To run tests against Chrome:
14
15* Download chromedriver for your host OS from
Patrick Williamsc0f7c042017-02-23 20:41:17 -060016 https://sites.google.com/a/chromium.org/chromedriver/downloads
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050017* On *nix systems, put chromedriver on PATH
18* On Windows, put chromedriver.exe in the same directory as chrome.exe
19
20To run tests against PhantomJS (headless):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021--NOTE - Selenium seems to be deprecating support for this mode ---
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050022* Download and install PhantomJS:
23 http://phantomjs.org/download.html
24* On *nix systems, put phantomjs on PATH
25* Not tested on Windows
26
Patrick Williamsc0f7c042017-02-23 20:41:17 -060027To run tests against Firefox, you may need to install the Marionette driver,
28depending on how new your version of Firefox is. One clue that you need to do
29this is if you see an exception like:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050030
Patrick Williamsc0f7c042017-02-23 20:41:17 -060031 selenium.common.exceptions.WebDriverException: Message: The browser
32 appears to have exited before we could connect. If you specified
33 a log_file in the FirefoxBinary constructor, check it for details.
34
35See https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
36for installation instructions. Ensure that the Marionette executable (renamed
37as wires on Linux or wires.exe on Windows) is on your PATH; and use "marionette"
38as the browser string passed via TOASTER_TESTS_BROWSER (see below).
39
40(Note: The Toaster tests have been checked against Firefox 47 with the
41Marionette driver.)
42
43The test cases will instantiate a Selenium driver set by the
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050044TOASTER_TESTS_BROWSER environment variable, or Chrome if this is not specified.
45
Brad Bishop6e60e8b2018-02-01 10:27:11 -050046To run tests against the Selenium Firefox Docker container:
47More explanation is located at https://wiki.yoctoproject.org/wiki/TipsAndTricks/TestingToasterWithContainers
48* Run the Selenium container:
49 ** docker run -it --rm=true -p 5900:5900 -p 4444:4444 --name=selenium selenium/standalone-firefox-debug:2.53.0
50 *** 5900 is the default vnc port. If you are runing a vnc server on your machine map a different port e.g. -p 6900:5900 and connect vnc client to 127.0.0.1:6900
51 *** 4444 is the default selenium sever port.
52* Run the tests
53 ** TOASTER_TESTS_BROWSER=http://127.0.0.1:4444/wd/hub TOASTER_TESTS_URL=http://172.17.0.1:8000 ./bitbake/lib/toaster/manage.py test --liveserver=172.17.0.1:8000 tests.browser
54 ** TOASTER_TESTS_BROWSER=remote TOASTER_REMOTE_HUB=http://127.0.0.1:4444/wd/hub ./bitbake/lib/toaster/manage.py test --liveserver=172.17.0.1:8000 tests.browser
55 *** TOASTER_REMOTE_HUB - This is the address for the Selenium Remote Web Driver hub. Assuming you ran the contianer with -p 4444:4444 it will be http://127.0.0.1:4444/wd/hub.
56 *** --liveserver=xxx tells Django to run the test server on an interface and port reachable by both host and container.
57 **** 172.17.0.1 is the default docker bridge on linux, viewable from inside and outside the contianers. Find it with "ip -4 addr show dev docker0"
58* connect to the vnc server to see the tests if you would like
59 ** xtightvncviewer 127.0.0.1:5900
60 ** note, you need to wait for the test container to come up before this can connect.
61
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050062Available drivers:
63
64* chrome (default)
65* firefox
Patrick Williamsc0f7c042017-02-23 20:41:17 -060066* marionette (for newer Firefoxes)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050067* ie
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068* phantomjs (deprecated)
69* remote
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050070
71e.g. to run the test suite with phantomjs where you have phantomjs installed
72in /home/me/apps/phantomjs:
73
74PATH=/home/me/apps/phantomjs/bin:$PATH TOASTER_TESTS_BROWSER=phantomjs manage.py test tests.browser