Add protocol option for selecting a Selenium Grid server
This commit is contained in:
parent
966f1693ba
commit
546e9bcbd7
|
@ -350,6 +350,7 @@ The code above will leave your browser window open in case there's a failure. (i
|
|||
--var2=DATA # (Extra test data. Access with "self.var2" in tests.)
|
||||
--var3=DATA # (Extra test data. Access with "self.var3" in tests.)
|
||||
--user-data-dir=DIR # (Set the Chrome user data directory to use.)
|
||||
--protocol=PROTOCOL # (The Selenium Grid protocol: http|https.)
|
||||
--server=SERVER # (The Selenium Grid server/IP used for tests.)
|
||||
--port=PORT # (The Selenium Grid port used by the test server.)
|
||||
--proxy=SERVER:PORT # (Connect to a proxy server:port for tests.)
|
||||
|
|
|
@ -35,6 +35,7 @@ if pure_python:
|
|||
sb.headed = False
|
||||
sb.start_page = None
|
||||
sb.locale_code = None
|
||||
sb.protocol = "http"
|
||||
sb.servername = "localhost"
|
||||
sb.port = 4444
|
||||
sb.data = None
|
||||
|
|
|
@ -105,6 +105,7 @@ SeleniumBase provides additional ``pytest`` command-line options for tests:
|
|||
--var2=DATA # (Extra test data. Access with "self.var2" in tests.)
|
||||
--var3=DATA # (Extra test data. Access with "self.var3" in tests.)
|
||||
--user-data-dir=DIR # (Set the Chrome user data directory to use.)
|
||||
--protocol=PROTOCOL # (The Selenium Grid protocol: http|https.)
|
||||
--server=SERVER # (The Selenium Grid server/IP used for tests.)
|
||||
--port=PORT # (The Selenium Grid port used by the test server.)
|
||||
--proxy=SERVER:PORT # (Connect to a proxy server:port for tests.)
|
||||
|
|
|
@ -536,6 +536,7 @@ def get_driver(
|
|||
headless=False,
|
||||
locale_code=None,
|
||||
use_grid=False,
|
||||
protocol="http",
|
||||
servername="localhost",
|
||||
port=4444,
|
||||
proxy_string=None,
|
||||
|
@ -602,6 +603,7 @@ def get_driver(
|
|||
browser_name,
|
||||
headless,
|
||||
locale_code,
|
||||
protocol,
|
||||
servername,
|
||||
port,
|
||||
proxy_string,
|
||||
|
@ -671,6 +673,7 @@ def get_remote_driver(
|
|||
browser_name,
|
||||
headless,
|
||||
locale_code,
|
||||
protocol,
|
||||
servername,
|
||||
port,
|
||||
proxy_string,
|
||||
|
@ -703,7 +706,7 @@ def get_remote_driver(
|
|||
device_pixel_ratio,
|
||||
):
|
||||
downloads_path = download_helper.get_downloads_folder()
|
||||
address = "http://%s:%s/wd/hub" % (servername, port)
|
||||
address = "%s://%s:%s/wd/hub" % (protocol, servername, port)
|
||||
desired_caps = {}
|
||||
extra_caps = {}
|
||||
if cap_file:
|
||||
|
|
|
@ -2206,6 +2206,7 @@ class BaseCase(unittest.TestCase):
|
|||
browser=None,
|
||||
headless=None,
|
||||
locale_code=None,
|
||||
protocol=None,
|
||||
servername=None,
|
||||
port=None,
|
||||
proxy=None,
|
||||
|
@ -2242,6 +2243,7 @@ class BaseCase(unittest.TestCase):
|
|||
browser - the browser to use. (Ex: "chrome", "firefox")
|
||||
headless - the option to run webdriver in headless mode
|
||||
locale_code - the Language Locale Code for the web browser
|
||||
protocol - if using a Selenium Grid, set the host protocol here
|
||||
servername - if using a Selenium Grid, set the host address here
|
||||
port - if using a Selenium Grid, set the host port here
|
||||
proxy - if using a proxy server, specify the "host:port" combo here
|
||||
|
@ -2302,6 +2304,8 @@ class BaseCase(unittest.TestCase):
|
|||
headless = self.headless
|
||||
if locale_code is None:
|
||||
locale_code = self.locale_code
|
||||
if protocol is None:
|
||||
protocol = self.protocol
|
||||
if servername is None:
|
||||
servername = self.servername
|
||||
if port is None:
|
||||
|
@ -2375,6 +2379,7 @@ class BaseCase(unittest.TestCase):
|
|||
headless=headless,
|
||||
locale_code=locale_code,
|
||||
use_grid=use_grid,
|
||||
protocol=protocol,
|
||||
servername=servername,
|
||||
port=port,
|
||||
proxy_string=proxy_string,
|
||||
|
@ -8367,6 +8372,7 @@ class BaseCase(unittest.TestCase):
|
|||
self.with_page_source = sb_config.with_page_source
|
||||
self.with_db_reporting = sb_config.with_db_reporting
|
||||
self.with_s3_logging = sb_config.with_s3_logging
|
||||
self.protocol = sb_config.protocol
|
||||
self.servername = sb_config.servername
|
||||
self.port = sb_config.port
|
||||
self.proxy_string = sb_config.proxy_string
|
||||
|
@ -8604,6 +8610,7 @@ class BaseCase(unittest.TestCase):
|
|||
browser=self.browser,
|
||||
headless=self.headless,
|
||||
locale_code=self.locale_code,
|
||||
protocol=self.protocol,
|
||||
servername=self.servername,
|
||||
port=self.port,
|
||||
proxy=self.proxy_string,
|
||||
|
|
|
@ -385,6 +385,11 @@ class Browser:
|
|||
}
|
||||
|
||||
|
||||
class Protocol:
|
||||
HTTP = "http"
|
||||
HTTPS = "https"
|
||||
|
||||
|
||||
class State:
|
||||
PASSED = "Passed"
|
||||
FAILED = "Failed"
|
||||
|
|
|
@ -33,6 +33,7 @@ def pytest_addoption(parser):
|
|||
--var2=DATA (Extra test data. Access with "self.var2" in tests.)
|
||||
--var3=DATA (Extra test data. Access with "self.var3" in tests.)
|
||||
--user-data-dir=DIR (Set the Chrome user data directory to use.)
|
||||
--protocol=PROTOCOL (The Selenium Grid protocol: http|https.)
|
||||
--server=SERVER (The Selenium Grid server/IP used for tests.)
|
||||
--port=PORT (The Selenium Grid port used by the test server.)
|
||||
--cap-file=FILE (The web browser's desired capabilities to use.)
|
||||
|
@ -334,6 +335,18 @@ def pytest_addoption(parser):
|
|||
This option saves page source files on test failures.
|
||||
(Automatically on when using --with-testing_base)""",
|
||||
)
|
||||
parser.addoption(
|
||||
"--protocol",
|
||||
action="store",
|
||||
dest="protocol",
|
||||
choices=(
|
||||
constants.Protocol.HTTP,
|
||||
constants.Protocol.HTTPS,
|
||||
),
|
||||
default=constants.Protocol.HTTP,
|
||||
help="""Designates the Selenium Grid protocol to use.
|
||||
Default: http.""",
|
||||
)
|
||||
parser.addoption(
|
||||
"--server",
|
||||
action="store",
|
||||
|
@ -911,6 +924,7 @@ def pytest_configure(config):
|
|||
sb_config.with_screen_shots = config.getoption("with_screen_shots")
|
||||
sb_config.with_basic_test_info = config.getoption("with_basic_test_info")
|
||||
sb_config.with_page_source = config.getoption("with_page_source")
|
||||
sb_config.protocol = config.getoption("protocol")
|
||||
sb_config.servername = config.getoption("servername")
|
||||
sb_config.port = config.getoption("port")
|
||||
sb_config.proxy_string = config.getoption("proxy_string")
|
||||
|
|
|
@ -14,6 +14,7 @@ class SeleniumBrowser(Plugin):
|
|||
This plugin adds the following command-line options to nosetests:
|
||||
--browser=BROWSER (The web browser to use. Default: "chrome".)
|
||||
--user-data-dir=DIR (Set the Chrome user data directory to use.)
|
||||
--protocol=PROTOCOL (The Selenium Grid protocol: http|https.)
|
||||
--server=SERVER (The Selenium Grid server/IP used for tests.)
|
||||
--port=PORT (The Selenium Grid port used by the test server.)
|
||||
--cap-file=FILE (The web browser's desired capabilities to use.)
|
||||
|
@ -111,6 +112,18 @@ class SeleniumBrowser(Plugin):
|
|||
help="""The Chrome User Data Directory to use. (Chrome Profile)
|
||||
If the directory doesn't exist, it'll be created.""",
|
||||
)
|
||||
parser.add_option(
|
||||
"--protocol",
|
||||
action="store",
|
||||
dest="protocol",
|
||||
choices=(
|
||||
constants.Protocol.HTTP,
|
||||
constants.Protocol.HTTPS,
|
||||
),
|
||||
default=constants.Protocol.HTTP,
|
||||
help="""Designates the Selenium Grid protocol to use.
|
||||
Default: http.""",
|
||||
)
|
||||
parser.add_option(
|
||||
"--server",
|
||||
action="store",
|
||||
|
@ -532,6 +545,7 @@ class SeleniumBrowser(Plugin):
|
|||
test.test.locale_code = self.options.locale_code
|
||||
test.test.interval = self.options.interval
|
||||
test.test.start_page = self.options.start_page
|
||||
test.test.protocol = self.options.protocol
|
||||
test.test.servername = self.options.servername
|
||||
test.test.port = self.options.port
|
||||
test.test.user_data_dir = self.options.user_data_dir
|
||||
|
|
Loading…
Reference in New Issue