Path: blob/trunk/py/test/unit/selenium/webdriver/common/common_options_tests.py
1990 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617import pytest1819from selenium.webdriver import Proxy20from selenium.webdriver.common.options import ArgOptions21from selenium.webdriver.common.proxy import ProxyType222324@pytest.fixture25def options():26return ArgOptions()272829def test_add_arguments(options):30options.add_argument("foo")31assert "foo" in options._arguments323334def test_get_arguments(options):35options._arguments = ["foo"]36assert "foo" in options.arguments373839def test_enables_mobile(options):40options.enable_mobile(android_package="cheese")41assert options.mobile_options["androidPackage"] == "cheese"42assert not hasattr(options.mobile_options, "androidActivity")43assert not hasattr(options.mobile_options, "androidDeviceSerial")444546def test_enable_mobile_errors_without_package(options):47with pytest.raises(AttributeError):48options.enable_mobile()495051def test_enable_mobile_with_activity(options):52options.enable_mobile(android_package="sausages", android_activity="eating")53assert options.mobile_options["androidActivity"] == "eating"545556def test_enable_mobile_with_device_serial(options):57options.enable_mobile(android_package="cheese", android_activity="crackers", device_serial="1234")58options.mobile_options["androidDeviceSerial"] == "1234"596061def test_missing_capabilities_return_false_rather_than_none():62options = ArgOptions()63assert options.strict_file_interactability is False64assert options.set_window_rect is False65assert options.accept_insecure_certs is False666768def test_add_proxy():69options = ArgOptions()70proxy = Proxy({"proxyType": ProxyType.MANUAL})71proxy.http_proxy = "http://user:password@http_proxy.com:8080"72options.proxy = proxy73caps = options.to_capabilities()7475assert options.proxy == proxy76assert caps.get("proxy") == proxy.to_capabilities()777879def test_default_bidi():80options = ArgOptions()81assert options.enable_bidi is False82assert options.web_socket_url is None838485def test_enable_bidi():86options = ArgOptions()87options.enable_bidi = True88assert options.enable_bidi is True89assert options.web_socket_url is None909192def test_set_socket_url():93options = ArgOptions()94options.web_socket_url = "socket_url"95assert options.enable_bidi is True96assert options.web_socket_url == "socket_url"979899