Path: blob/trunk/py/test/unit/selenium/webdriver/ie/test_ie_options.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.161718import pytest1920from selenium.webdriver.common.options import PageLoadStrategy21from selenium.webdriver.ie.options import ElementScrollBehavior, Options2223TIMEOUT = 30242526@pytest.fixture27def opts():28yield Options()293031def test_arguments(opts):32arg1 = "-k"33arg2 = "-private"34opts.add_argument(arg1)35opts.add_argument(arg2)36assert arg1 in opts.arguments37assert arg2 in opts.arguments383940def test_browser_attach_timeout(opts):41opts.browser_attach_timeout = TIMEOUT42assert opts.browser_attach_timeout == TIMEOUT43assert opts.options.get(Options.BROWSER_ATTACH_TIMEOUT) == TIMEOUT444546def test_raises_exception_for_invalid_browser_attach_timeout(opts):47with pytest.raises(ValueError):48opts.browser_attach_timeout = "foo"495051def test_element_scroll_behavior(opts):52opts.element_scroll_behavior = ElementScrollBehavior.BOTTOM53assert opts.element_scroll_behavior == ElementScrollBehavior.BOTTOM54assert opts.options.get(Options.ELEMENT_SCROLL_BEHAVIOR) == ElementScrollBehavior.BOTTOM555657def test_ensure_clean_session(opts):58opts.ensure_clean_session = True59assert opts.ensure_clean_session is True60assert opts.options.get(Options.ENSURE_CLEAN_SESSION) is True616263def test_file_upload_dialog_timeout(opts):64opts.file_upload_dialog_timeout = TIMEOUT65assert opts.file_upload_dialog_timeout is TIMEOUT66assert opts.options.get(Options.FILE_UPLOAD_DIALOG_TIMEOUT) is TIMEOUT676869def test_raises_exception_for_file_upload_dialog_timeout(opts):70with pytest.raises(ValueError):71opts.file_upload_dialog_timeout = "foo"727374def test_force_create_process_api(opts):75opts.force_create_process_api = True76assert opts.force_create_process_api is True77assert opts.options.get(Options.FORCE_CREATE_PROCESS_API) is True787980def test_force_shell_windows_api(opts):81opts.force_shell_windows_api = True82assert opts.force_shell_windows_api is True83assert opts.options.get(Options.FORCE_SHELL_WINDOWS_API) is True848586def test_full_page_screenshot(opts):87opts.full_page_screenshot = True88assert opts.full_page_screenshot is True89assert opts.options.get(Options.FULL_PAGE_SCREENSHOT) is True909192def test_ignore_protected_mode_settings(opts):93opts.ignore_protected_mode_settings = True94assert opts.ignore_protected_mode_settings is True95assert opts.options.get(Options.IGNORE_PROTECTED_MODE_SETTINGS) is True969798def test_ignore_zoom_level(opts):99opts.ignore_zoom_level = True100assert opts.ignore_zoom_level is True101assert opts.options.get(Options.IGNORE_ZOOM_LEVEL) is True102103104def test_initial_browser_url(opts):105url = "http://www.selenium.dev"106opts.initial_browser_url = url107assert opts.initial_browser_url == url108assert opts.options.get(Options.INITIAL_BROWSER_URL) == url109110111def test_native_events(opts):112opts.native_events = True113assert opts.native_events is True114assert opts.options.get(Options.NATIVE_EVENTS) is True115116117def test_persistent_hover(opts):118opts.persistent_hover = True119assert opts.persistent_hover is True120assert opts.options.get(Options.PERSISTENT_HOVER) is True121122123def test_require_window_focus(opts):124opts.require_window_focus = True125assert opts.require_window_focus is True126assert opts.options.get(Options.REQUIRE_WINDOW_FOCUS) is True127128129def test_use_per_process_proxy(opts):130opts.use_per_process_proxy = True131assert opts.use_per_process_proxy is True132assert opts.options.get(Options.USE_PER_PROCESS_PROXY) is True133134135def test_use_legacy_file_upload_dialog_handling(opts):136opts.use_legacy_file_upload_dialog_handling = True137assert opts.use_legacy_file_upload_dialog_handling is True138assert opts.options.get(Options.USE_LEGACY_FILE_UPLOAD_DIALOG_HANDLING) is True139140141def test_attach_to_edge_chrome(opts):142opts.attach_to_edge_chrome = True143assert opts.attach_to_edge_chrome is True144assert opts.options.get(Options.ATTACH_TO_EDGE_CHROME) is True145146147def test_edge_executable_path(opts):148path = "/path/to/edge"149opts.edge_executable_path = path150assert opts.edge_executable_path == path151assert opts.options.get(Options.EDGE_EXECUTABLE_PATH) == path152153154def test_additional_options(opts):155opts.add_additional_option("foo", "bar")156assert opts.additional_options.get("foo") == "bar"157158159def test_to_capabilities(opts):160opts._options["foo"] = "bar"161assert Options.KEY in opts.to_capabilities()162assert opts.to_capabilities().get(Options.KEY) == opts._options163164165def test_to_capabilities_arguments(opts):166arg = "-k"167opts.add_argument(arg)168caps_opts = opts.to_capabilities().get(Options.KEY)169assert caps_opts.get(Options.SWITCHES) == arg170171172def test_to_capabilities_additional_options(opts):173name = "foo"174value = "bar"175opts.add_additional_option(name, value)176caps_opts = opts.to_capabilities().get(Options.KEY)177assert caps_opts.get(name) == value178179180def test_to_capabilities_should_not_modify_set_options(opts):181opts._options["foo"] = "bar"182arg = "-k"183opts.add_argument(arg)184opts.add_additional_option("baz", "qux")185opts.to_capabilities().get(Options.KEY)186assert opts.options.get("foo") == "bar"187assert opts.arguments[0] == arg188assert opts.additional_options.get("baz") == "qux"189190191def test_starts_with_default_capabilities(opts):192from selenium.webdriver import DesiredCapabilities193194caps = DesiredCapabilities.INTERNETEXPLORER.copy()195caps.update({"pageLoadStrategy": PageLoadStrategy.normal})196assert opts._caps == caps197198199def test_is_a_baseoptions(opts):200from selenium.webdriver.common.options import BaseOptions201202assert isinstance(opts, BaseOptions)203204205