Debian Codegraph @

test/unit/selenium/webdriver/ie/test_ie_options.py

raw symbols SCIP
1 # Licensed to the Software Freedom Conservancy (SFC) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The SFC licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17
18
19 import pytest
20
21 from selenium.webdriver.common.options import PageLoadStrategy
22 from selenium.webdriver.ie.options import ElementScrollBehavior
23 from selenium.webdriver.ie.options import Options
24
25 TIMEOUT = 30
26
27
28 @pytest.fixture
29 def opts():
30 yield Options()
31
32
33 def test_arguments(opts):
34 arg1 = "-k"
35 arg2 = "-private"
36 opts.add_argument(arg1)
37 opts.add_argument(arg2)
38 assert arg1 in opts.arguments
39 assert arg2 in opts.arguments
40
41
42 def test_browser_attach_timeout(opts):
43 opts.browser_attach_timeout = TIMEOUT
44 assert opts.browser_attach_timeout == TIMEOUT
45 assert opts.options.get(Options.BROWSER_ATTACH_TIMEOUT) == TIMEOUT
46
47
48 def test_raises_exception_for_invalid_browser_attach_timeout(opts):
49 with pytest.raises(ValueError):
50 opts.browser_attach_timeout = "foo"
51
52
53 def test_element_scroll_behavior(opts):
54 opts.element_scroll_behavior = ElementScrollBehavior.BOTTOM
55 assert opts.element_scroll_behavior == ElementScrollBehavior.BOTTOM
56 assert opts.options.get(Options.ELEMENT_SCROLL_BEHAVIOR) == ElementScrollBehavior.BOTTOM
57
58
59 def test_ensure_clean_session(opts):
60 opts.ensure_clean_session = True
61 assert opts.ensure_clean_session is True
62 assert opts.options.get(Options.ENSURE_CLEAN_SESSION) is True
63
64
65 def test_file_upload_dialog_timeout(opts):
66 opts.file_upload_dialog_timeout = TIMEOUT
67 assert opts.file_upload_dialog_timeout is TIMEOUT
68 assert opts.options.get(Options.FILE_UPLOAD_DIALOG_TIMEOUT) is TIMEOUT
69
70
71 def test_raises_exception_for_file_upload_dialog_timeout(opts):
72 with pytest.raises(ValueError):
73 opts.file_upload_dialog_timeout = "foo"
74
75
76 def test_force_create_process_api(opts):
77 opts.force_create_process_api = True
78 assert opts.force_create_process_api is True
79 assert opts.options.get(Options.FORCE_CREATE_PROCESS_API) is True
80
81
82 def test_force_shell_windows_api(opts):
83 opts.force_shell_windows_api = True
84 assert opts.force_shell_windows_api is True
85 assert opts.options.get(Options.FORCE_SHELL_WINDOWS_API) is True
86
87
88 def test_full_page_screenshot(opts):
89 opts.full_page_screenshot = True
90 assert opts.full_page_screenshot is True
91 assert opts.options.get(Options.FULL_PAGE_SCREENSHOT) is True
92
93
94 def test_ignore_protected_mode_settings(opts):
95 opts.ignore_protected_mode_settings = True
96 assert opts.ignore_protected_mode_settings is True
97 assert opts.options.get(Options.IGNORE_PROTECTED_MODE_SETTINGS) is True
98
99
100 def test_ignore_zoom_level(opts):
101 opts.ignore_zoom_level = True
102 assert opts.ignore_zoom_level is True
103 assert opts.options.get(Options.IGNORE_ZOOM_LEVEL) is True
104
105
106 def test_initial_browser_url(opts):
107 url = "http://www.selenium.dev"
108 opts.initial_browser_url = url
109 assert opts.initial_browser_url == url
110 assert opts.options.get(Options.INITIAL_BROWSER_URL) == url
111
112
113 def test_native_events(opts):
114 opts.native_events = True
115 assert opts.native_events is True
116 assert opts.options.get(Options.NATIVE_EVENTS) is True
117
118
119 def test_persistent_hover(opts):
120 opts.persistent_hover = True
121 assert opts.persistent_hover is True
122 assert opts.options.get(Options.PERSISTENT_HOVER) is True
123
124
125 def test_require_window_focus(opts):
126 opts.require_window_focus = True
127 assert opts.require_window_focus is True
128 assert opts.options.get(Options.REQUIRE_WINDOW_FOCUS) is True
129
130
131 def test_use_per_process_proxy(opts):
132 opts.use_per_process_proxy = True
133 assert opts.use_per_process_proxy is True
134 assert opts.options.get(Options.USE_PER_PROCESS_PROXY) is True
135
136
137 def test_use_legacy_file_upload_dialog_handling(opts):
138 opts.use_legacy_file_upload_dialog_handling = True
139 assert opts.use_legacy_file_upload_dialog_handling is True
140 assert opts.options.get(Options.USE_LEGACY_FILE_UPLOAD_DIALOG_HANDLING) is True
141
142
143 def test_attach_to_edge_chrome(opts):
144 opts.attach_to_edge_chrome = True
145 assert opts.attach_to_edge_chrome is True
146 assert opts.options.get(Options.ATTACH_TO_EDGE_CHROME) is True
147
148
149 def test_edge_executable_path(opts):
150 path = "/path/to/edge"
151 opts.edge_executable_path = path
152 assert opts.edge_executable_path == path
153 assert opts.options.get(Options.EDGE_EXECUTABLE_PATH) == path
154
155
156 def test_additional_options(opts):
157 opts.add_additional_option("foo", "bar")
158 assert opts.additional_options.get("foo") == "bar"
159
160
161 def test_to_capabilities(opts):
162 opts._options["foo"] = "bar"
163 assert Options.KEY in opts.to_capabilities()
164 assert opts.to_capabilities().get(Options.KEY) == opts._options
165
166
167 def test_to_capabilities_arguments(opts):
168 arg = "-k"
169 opts.add_argument(arg)
170 caps_opts = opts.to_capabilities().get(Options.KEY)
171 assert caps_opts.get(Options.SWITCHES) == arg
172
173
174 def test_to_capabilities_additional_options(opts):
175 name = "foo"
176 value = "bar"
177 opts.add_additional_option(name, value)
178 caps_opts = opts.to_capabilities().get(Options.KEY)
179 assert caps_opts.get(name) == value
180
181
182 def test_to_capabilities_should_not_modify_set_options(opts):
183 opts._options["foo"] = "bar"
184 arg = "-k"
185 opts.add_argument(arg)
186 opts.add_additional_option("baz", "qux")
187 opts.to_capabilities().get(Options.KEY)
188 assert opts.options.get("foo") == "bar"
189 assert opts.arguments[0] == arg
190 assert opts.additional_options.get("baz") == "qux"
191
192
193 def test_starts_with_default_capabilities(opts):
194 from selenium.webdriver import DesiredCapabilities
195
196 caps = DesiredCapabilities.INTERNETEXPLORER.copy()
197 caps.update({"pageLoadStrategy": PageLoadStrategy.normal})
198 assert opts._caps == caps
199
200
201 def test_is_a_baseoptions(opts):
202 from selenium.webdriver.common.options import BaseOptions
203
204 assert isinstance(opts, BaseOptions)