|
1 |
| -""" |
2 |
| -This plugin gives the power of Selenium to nosetests |
3 |
| -by providing a WebDriver object for the tests to use. |
4 |
| -""" |
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +""" This is the nosetests Selenium plugin for test configuration. """ |
5 | 3 |
|
6 | 4 | import sys
|
7 | 5 | from nose.plugins import Plugin
|
|
11 | 9 |
|
12 | 10 | class SeleniumBrowser(Plugin):
|
13 | 11 | """
|
14 |
| - The plugin for Selenium tests. Takes in key arguments and then |
15 |
| - creates a WebDriver object. All arguments are passed to the tests. |
16 |
| -
|
17 |
| - The following command line options are available to the tests: |
18 |
| - self.options.browser -- the browser to use (--browser) |
19 |
| - self.options.cap_file -- browser's desired capabilities file (--cap_file) |
20 |
| - self.options.user_data_dir -- set Chrome's user data dir (--user_data_dir) |
21 |
| - self.options.server -- the server used by the test (--server) |
22 |
| - self.options.port -- the port used by the test (--port) |
23 |
| - self.options.proxy -- designates the proxy server:port to use. (--proxy) |
24 |
| - self.options.agent -- designates the User Agent for the browser. (--agent) |
25 |
| - self.options.extension_zip -- load a Chrome Extension ZIP (--extension_zip) |
26 |
| - self.options.extension_dir -- load a Chrome Extension DIR (--extension_dir) |
27 |
| - self.options.headless -- the option to run headlessly (--headless) |
28 |
| - self.options.headed -- the option to run with a GUI on Linux (--headed) |
29 |
| - self.options.demo_mode -- the option to slow down Selenium (--demo_mode) |
30 |
| - self.options.demo_sleep -- Selenium action delay in DemoMode (--demo_sleep) |
31 |
| - self.options.highlights -- # of highlight animations shown (--highlights) |
32 |
| - self.options.message_duration -- Messenger alert time (--message_duration) |
33 |
| - self.options.js_checking_on -- option to check for js errors (--check_js) |
34 |
| - self.options.ad_block -- the option to block some display ads (--ad_block) |
35 |
| - self.options.verify_delay -- delay before MasterQA checks (--verify_delay) |
36 |
| - self.options.disable_csp -- disable Content Security Policy (--disable_csp) |
37 |
| - self.options.enable_sync -- option to enable "Chrome Sync" (--enable_sync) |
38 |
| - self.options.save_screenshot -- save screen after test (--save_screenshot) |
39 |
| - self.options.visual_baseline -- set the visual baseline (--visual_baseline) |
40 |
| - self.options.timeout_multiplier -- increase defaults (--timeout_multiplier) |
| 12 | + This parser plugin includes the following command-line options for Nose: |
| 13 | + --browser=BROWSER (The web browser to use.) |
| 14 | + --cap_file=FILE (The web browser's desired capabilities to use.) |
| 15 | + --user_data_dir=DIR (Set the Chrome user data directory to use.) |
| 16 | + --server=SERVER (The server / IP address used by the tests.) |
| 17 | + --port=PORT (The port that's used by the test server.) |
| 18 | + --proxy=SERVER:PORT (This is the proxy server:port combo used by tests.) |
| 19 | + --agent=STRING (This designates the web browser's User Agent to use.) |
| 20 | + --extension_zip=ZIP (Load a Chrome Extension .zip file, comma-separated.) |
| 21 | + --extension_dir=DIR (Load a Chrome Extension directory, comma-separated.) |
| 22 | + --headless (The option to run tests headlessly. The default on Linux OS.) |
| 23 | + --headed (The option to run tests with a GUI on Linux OS.) |
| 24 | + --start_page=URL (The starting URL for the web browser when tests begin.) |
| 25 | + --demo_mode (The option to visually see test actions as they occur.) |
| 26 | + --demo_sleep=SECONDS (The option to wait longer after Demo Mode actions.) |
| 27 | + --highlights=NUM (Number of highlight animations for Demo Mode actions.) |
| 28 | + --message_duration=SECONDS (The time length for Messenger alerts.) |
| 29 | + --check_js (The option to check for JavaScript errors after page loads.) |
| 30 | + --ad_block (The option to block some display ads after page loads.) |
| 31 | + --verify_delay=SECONDS (The delay before MasterQA verification checks.) |
| 32 | + --disable_csp (This disables the Content Security Policy of websites.) |
| 33 | + --enable_sync (The option to enable "Chrome Sync".) |
| 34 | + --save_screenshot (The option to save a screenshot after each test.) |
| 35 | + --visual_baseline (Set the visual baseline for Visual/Layout tests.) |
| 36 | + --timeout_multiplier=MULTIPLIER (Multiplies the default timeout values.) |
41 | 37 | """
|
42 | 38 | name = 'selenium' # Usage: --with-selenium
|
43 | 39 |
|
@@ -141,6 +137,14 @@ def options(self, parser, env):
|
141 | 137 | a GUI when running tests on Linux machines.
|
142 | 138 | (The default setting on Linux is headless.)
|
143 | 139 | (The default setting on Mac or Windows is headed.)""")
|
| 140 | + parser.add_option( |
| 141 | + '--start_page', '--start-page', '--url', |
| 142 | + action='store', |
| 143 | + dest='start_page', |
| 144 | + default=None, |
| 145 | + help="""Designates the starting URL for the web browser |
| 146 | + when each test begins. |
| 147 | + Default: None.""") |
144 | 148 | parser.add_option(
|
145 | 149 | '--demo_mode', '--demo-mode', '--demo',
|
146 | 150 | action="store_true",
|
@@ -245,6 +249,7 @@ def beforeTest(self, test):
|
245 | 249 | test.test.cap_file = self.options.cap_file
|
246 | 250 | test.test.headless = self.options.headless
|
247 | 251 | test.test.headed = self.options.headed
|
| 252 | + test.test.start_page = self.options.start_page |
248 | 253 | test.test.servername = self.options.servername
|
249 | 254 | test.test.port = self.options.port
|
250 | 255 | test.test.user_data_dir = self.options.user_data_dir
|
@@ -281,7 +286,7 @@ def beforeTest(self, test):
|
281 | 286 | if self.options.headless:
|
282 | 287 | try:
|
283 | 288 | from pyvirtualdisplay import Display
|
284 |
| - self.display = Display(visible=0, size=(1440, 1080)) |
| 289 | + self.display = Display(visible=0, size=(1440, 1880)) |
285 | 290 | self.display.start()
|
286 | 291 | self.headless_active = True
|
287 | 292 | except Exception:
|
|
0 commit comments