Skip to content

Commit 5ba7a42

Browse files
Add support for https protocol for Remote drivers (#272)
* Add support for https protocol for Remote drivers * Update pre-commit black version
1 parent 2f76e44 commit 5ba7a42

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 22.1.0
3+
rev: 22.3.0
44
hooks:
55
- id: black
66
args: [--safe, --quiet]

src/pytest_selenium/drivers/appium.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010

1111
def driver_kwargs(capabilities, host, port, **kwargs):
12-
executor = "http://{0}:{1}/wd/hub".format(host, port)
12+
host = host if host.startswith("http") else f"http://{host}"
13+
executor = f"{host}:{port}/wd/hub"
14+
1315
kwargs = {"command_executor": executor, "desired_capabilities": capabilities}
1416
return kwargs

src/pytest_selenium/drivers/remote.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010

1111
def driver_kwargs(capabilities, host, port, **kwargs):
12-
executor = "http://{0}:{1}/wd/hub".format(host, port)
12+
host = host if host.startswith("http") else f"http://{host}"
13+
executor = f"{host}:{port}/wd/hub"
1314

1415
kwargs = {
1516
"command_executor": executor,

testing/test_driver.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,37 @@ def test_pass(driver_kwargs):
107107
testdir.quick_qa("--driver", "Remote", file_test, passed=1)
108108

109109

110+
@pytest.mark.parametrize(
111+
("host", "expected"),
112+
[
113+
("https://some.host.com", "https://some.host.com"),
114+
("http://some.host.com", "http://some.host.com"),
115+
("some.host.com", "http://some.host.com"),
116+
],
117+
)
118+
def test_host_protocol(host, expected, testdir):
119+
filetest = testdir.makepyfile(
120+
"""
121+
import pytest
122+
@pytest.mark.nondestructive
123+
def test_pass(driver_kwargs):
124+
assert driver_kwargs['command_executor'] == '{}:4444/wd/hub'
125+
""".format(
126+
expected
127+
)
128+
)
129+
testdir.quick_qa(
130+
"--driver",
131+
"Remote",
132+
"--selenium-host",
133+
host,
134+
"--selenium-port",
135+
"4444",
136+
filetest,
137+
passed=1,
138+
)
139+
140+
110141
@pytest.mark.parametrize(
111142
("host_arg_name", "port_arg_name", "context"),
112143
[

0 commit comments

Comments
 (0)