| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
import pytest |
| 19 |
|
| 20 |
from selenium.webdriver import Proxy |
| 21 |
from selenium.webdriver.common.options import ArgOptions |
| 22 |
from selenium.webdriver.common.proxy import ProxyType |
| 23 |
|
| 24 |
|
| 25 |
@pytest.fixture |
| 26 |
def options(): |
| 27 |
return ArgOptions() |
| 28 |
|
| 29 |
|
| 30 |
def test_add_arguments(options): |
| 31 |
options.add_argument("foo") |
| 32 |
assert "foo" in options._arguments |
| 33 |
|
| 34 |
|
| 35 |
def test_get_arguments(options): |
| 36 |
options._arguments = ["foo"] |
| 37 |
assert "foo" in options.arguments |
| 38 |
|
| 39 |
|
| 40 |
def test_enables_mobile(options): |
| 41 |
options.enable_mobile(android_package="cheese") |
| 42 |
assert options.mobile_options["androidPackage"] == "cheese" |
| 43 |
assert not hasattr(options.mobile_options, "androidActivity") |
| 44 |
assert not hasattr(options.mobile_options, "androidDeviceSerial") |
| 45 |
|
| 46 |
|
| 47 |
def test_enable_mobile_errors_without_package(options): |
| 48 |
with pytest.raises(AttributeError): |
| 49 |
options.enable_mobile() |
| 50 |
|
| 51 |
|
| 52 |
def test_enable_mobile_with_activity(options): |
| 53 |
options.enable_mobile(android_package="sausages", android_activity="eating") |
| 54 |
assert options.mobile_options["androidActivity"] == "eating" |
| 55 |
|
| 56 |
|
| 57 |
def test_enable_mobile_with_device_serial(options): |
| 58 |
options.enable_mobile(android_package="cheese", android_activity="crackers", device_serial="1234") |
| 59 |
options.mobile_options["androidDeviceSerial"] == "1234" |
| 60 |
|
| 61 |
|
| 62 |
def test_missing_capabilities_return_false_rather_than_none(): |
| 63 |
options = ArgOptions() |
| 64 |
assert options.strict_file_interactability is False |
| 65 |
assert options.set_window_rect is False |
| 66 |
assert options.accept_insecure_certs is False |
| 67 |
|
| 68 |
|
| 69 |
def test_add_proxy(): |
| 70 |
options = ArgOptions() |
| 71 |
proxy = Proxy({"proxyType": ProxyType.MANUAL}) |
| 72 |
proxy.http_proxy = "http://user:password@http_proxy.com:8080" |
| 73 |
options.proxy = proxy |
| 74 |
caps = options.to_capabilities() |
| 75 |
|
| 76 |
assert options.proxy == proxy |
| 77 |
assert caps.get("proxy") == proxy.to_capabilities() |
| 78 |
|
| 79 |
|
| 80 |
def test_default_bidi(): |
| 81 |
options = ArgOptions() |
| 82 |
assert options.enable_bidi is False |
| 83 |
assert options.web_socket_url is None |
| 84 |
|
| 85 |
|
| 86 |
def test_enable_bidi(): |
| 87 |
options = ArgOptions() |
| 88 |
options.enable_bidi = True |
| 89 |
assert options.enable_bidi is True |
| 90 |
assert options.web_socket_url is None |
| 91 |
|
| 92 |
|
| 93 |
def test_set_socket_url(): |
| 94 |
options = ArgOptions() |
| 95 |
options.web_socket_url = "socket_url" |
| 96 |
assert options.enable_bidi is True |
| 97 |
assert options.web_socket_url == "socket_url" |