Skip to content

Commit

Permalink
Add support for https protocol for Remote drivers (#272)
Browse files Browse the repository at this point in the history
* Add support for https protocol for Remote drivers

* Update pre-commit black version
  • Loading branch information
platonoff-dev committed Apr 4, 2022
1 parent 2f76e44 commit 5ba7a42
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 22.1.0
rev: 22.3.0
hooks:
- id: black
args: [--safe, --quiet]
Expand Down
4 changes: 3 additions & 1 deletion src/pytest_selenium/drivers/appium.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@


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

kwargs = {"command_executor": executor, "desired_capabilities": capabilities}
return kwargs
3 changes: 2 additions & 1 deletion src/pytest_selenium/drivers/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@


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

kwargs = {
"command_executor": executor,
Expand Down
31 changes: 31 additions & 0 deletions testing/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,37 @@ def test_pass(driver_kwargs):
testdir.quick_qa("--driver", "Remote", file_test, passed=1)


@pytest.mark.parametrize(
("host", "expected"),
[
("https://some.host.com", "https://some.host.com"),
("http://some.host.com", "http://some.host.com"),
("some.host.com", "http://some.host.com"),
],
)
def test_host_protocol(host, expected, testdir):
filetest = testdir.makepyfile(
"""
import pytest
@pytest.mark.nondestructive
def test_pass(driver_kwargs):
assert driver_kwargs['command_executor'] == '{}:4444/wd/hub'
""".format(
expected
)
)
testdir.quick_qa(
"--driver",
"Remote",
"--selenium-host",
host,
"--selenium-port",
"4444",
filetest,
passed=1,
)


@pytest.mark.parametrize(
("host_arg_name", "port_arg_name", "context"),
[
Expand Down

0 comments on commit 5ba7a42

Please sign in to comment.