xref: /OK3568_Linux_fs/yocto/poky/bitbake/lib/toaster/tests/browser/README (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# Running Toaster's browser-based test suite
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunThese tests require Selenium to be installed in your Python environment.
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunThe simplest way to install this is via pip3:
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun  pip3 install selenium==2.53.2
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunNote that if you use other versions of Selenium, some of the tests (such as
10*4882a593Smuzhiyuntests.browser.test_js_unit_tests.TestJsUnitTests) may fail, as these rely on
11*4882a593Smuzhiyuna Selenium test report with a version-specific format.
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunTo run tests against Chrome:
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun* Download chromedriver for your host OS from
16*4882a593Smuzhiyun  https://sites.google.com/a/chromium.org/chromedriver/downloads
17*4882a593Smuzhiyun* On *nix systems, put chromedriver on PATH
18*4882a593Smuzhiyun* On Windows, put chromedriver.exe in the same directory as chrome.exe
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunTo run tests against PhantomJS (headless):
21*4882a593Smuzhiyun--NOTE - Selenium seems to be deprecating support for this mode ---
22*4882a593Smuzhiyun* Download and install PhantomJS:
23*4882a593Smuzhiyun  http://phantomjs.org/download.html
24*4882a593Smuzhiyun* On *nix systems, put phantomjs on PATH
25*4882a593Smuzhiyun* Not tested on Windows
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunTo run tests against Firefox, you may need to install the Marionette driver,
28*4882a593Smuzhiyundepending on how new your version of Firefox is. One clue that you need to do
29*4882a593Smuzhiyunthis is if you see an exception like:
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun  selenium.common.exceptions.WebDriverException: Message: The browser
32*4882a593Smuzhiyun  appears to have exited before we could connect. If you specified
33*4882a593Smuzhiyun  a log_file in the FirefoxBinary constructor, check it for details.
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunSee https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
36*4882a593Smuzhiyunfor installation instructions. Ensure that the Marionette executable (renamed
37*4882a593Smuzhiyunas wires on Linux or wires.exe on Windows) is on your PATH; and use "marionette"
38*4882a593Smuzhiyunas the browser string passed via TOASTER_TESTS_BROWSER (see below).
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun(Note: The Toaster tests have been checked against Firefox 47 with the
41*4882a593SmuzhiyunMarionette driver.)
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunThe test cases will instantiate a Selenium driver set by the
44*4882a593SmuzhiyunTOASTER_TESTS_BROWSER environment variable, or Chrome if this is not specified.
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunTo run tests against the Selenium Firefox Docker container:
47*4882a593SmuzhiyunMore explanation is located at https://wiki.yoctoproject.org/wiki/TipsAndTricks/TestingToasterWithContainers
48*4882a593Smuzhiyun* Run the Selenium container:
49*4882a593Smuzhiyun  ** docker run -it --rm=true -p 5900:5900 -p 4444:4444 --name=selenium selenium/standalone-firefox-debug:2.53.0
50*4882a593Smuzhiyun  *** 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*4882a593Smuzhiyun  *** 4444 is the default selenium sever port.
52*4882a593Smuzhiyun* Run the tests
53*4882a593Smuzhiyun  ** 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*4882a593Smuzhiyun  ** 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*4882a593Smuzhiyun  *** 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*4882a593Smuzhiyun  ***  --liveserver=xxx tells Django to run the test server on an interface and port reachable by both host and container.
57*4882a593Smuzhiyun  **** 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*4882a593Smuzhiyun* connect to the vnc server to see the tests if you would like
59*4882a593Smuzhiyun   ** xtightvncviewer 127.0.0.1:5900
60*4882a593Smuzhiyun   ** note, you need to wait for the test container to come up before this can connect.
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunAvailable drivers:
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun* chrome (default)
65*4882a593Smuzhiyun* firefox
66*4882a593Smuzhiyun* marionette (for newer Firefoxes)
67*4882a593Smuzhiyun* ie
68*4882a593Smuzhiyun* phantomjs (deprecated)
69*4882a593Smuzhiyun* remote
70*4882a593Smuzhiyun
71*4882a593Smuzhiyune.g. to run the test suite with phantomjs where you have phantomjs installed
72*4882a593Smuzhiyunin /home/me/apps/phantomjs:
73*4882a593Smuzhiyun
74*4882a593SmuzhiyunPATH=/home/me/apps/phantomjs/bin:$PATH TOASTER_TESTS_BROWSER=phantomjs manage.py test tests.browser
75