15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
17
18
- """
19
- Exceptions that may happen in all the webdriver code.
20
- """
18
+ """Exceptions that may happen in all the webdriver code."""
21
19
22
20
from typing import Optional
23
21
from typing import Sequence
24
22
25
23
26
24
class WebDriverException (Exception ):
27
- """
28
- Base webdriver exception.
29
- """
25
+ """Base webdriver exception."""
30
26
31
27
def __init__ (
32
28
self , msg : Optional [str ] = None , screen : Optional [str ] = None , stacktrace : Optional [Sequence [str ]] = None
@@ -47,32 +43,25 @@ def __str__(self) -> str:
47
43
48
44
49
45
class InvalidSwitchToTargetException (WebDriverException ):
50
- """
51
- Thrown when frame or window target to be switched doesn't exist.
52
- """
46
+ """Thrown when frame or window target to be switched doesn't exist."""
53
47
54
48
55
49
class NoSuchFrameException (InvalidSwitchToTargetException ):
56
- """
57
- Thrown when frame target to be switched doesn't exist.
58
- """
50
+ """Thrown when frame target to be switched doesn't exist."""
59
51
60
52
61
53
class NoSuchWindowException (InvalidSwitchToTargetException ):
62
- """
63
- Thrown when window target to be switched doesn't exist.
54
+ """Thrown when window target to be switched doesn't exist.
64
55
65
56
To find the current set of active window handles, you can get a list
66
57
of the active window handles in the following way::
67
58
68
59
print driver.window_handles
69
-
70
60
"""
71
61
72
62
73
63
class NoSuchElementException (WebDriverException ):
74
- """
75
- Thrown when element could not be found.
64
+ """Thrown when element could not be found.
76
65
77
66
If you encounter this exception, you may want to check the following:
78
67
* Check your selector used in your find_by...
@@ -83,25 +72,22 @@ class NoSuchElementException(WebDriverException):
83
72
84
73
85
74
class NoSuchAttributeException (WebDriverException ):
86
- """
87
- Thrown when the attribute of element could not be found.
75
+ """Thrown when the attribute of element could not be found.
88
76
89
- You may want to check if the attribute exists in the particular browser you are
90
- testing against. Some browsers may have different property names for the same
91
- property. (IE8's .innerText vs. Firefox .textContent)
77
+ You may want to check if the attribute exists in the particular
78
+ browser you are testing against. Some browsers may have different
79
+ property names for the same property. (IE8's .innerText vs. Firefox
80
+ .textContent)
92
81
"""
93
82
94
83
95
84
class NoSuchShadowRootException (WebDriverException ):
96
- """
97
- Thrown when trying to access the shadow root of an element when it does not
98
- have a shadow root attached.
99
- """
85
+ """Thrown when trying to access the shadow root of an element when it does
86
+ not have a shadow root attached."""
100
87
101
88
102
89
class StaleElementReferenceException (WebDriverException ):
103
- """
104
- Thrown when a reference to an element is now "stale".
90
+ """Thrown when a reference to an element is now "stale".
105
91
106
92
Stale means the element no longer appears on the DOM of the page.
107
93
@@ -118,19 +104,19 @@ class StaleElementReferenceException(WebDriverException):
118
104
119
105
120
106
class InvalidElementStateException (WebDriverException ):
121
- """
122
- Thrown when a command could not be completed because the element is in an invalid state.
107
+ """Thrown when a command could not be completed because the element is in
108
+ an invalid state.
123
109
124
- This can be caused by attempting to clear an element that isn't both editable and resettable.
110
+ This can be caused by attempting to clear an element that isn't both
111
+ editable and resettable.
125
112
"""
126
113
127
114
128
115
class UnexpectedAlertPresentException (WebDriverException ):
129
- """
130
- Thrown when an unexpected alert has appeared.
116
+ """Thrown when an unexpected alert has appeared.
131
117
132
- Usually raised when an unexpected modal is blocking the webdriver from executing
133
- commands.
118
+ Usually raised when an unexpected modal is blocking the webdriver
119
+ from executing commands.
134
120
"""
135
121
136
122
def __init__ (
@@ -148,156 +134,123 @@ def __str__(self) -> str:
148
134
149
135
150
136
class NoAlertPresentException (WebDriverException ):
151
- """
152
- Thrown when switching to no presented alert.
137
+ """Thrown when switching to no presented alert.
153
138
154
- This can be caused by calling an operation on the Alert() class when an alert is
155
- not yet on the screen.
139
+ This can be caused by calling an operation on the Alert() class when
140
+ an alert is not yet on the screen.
156
141
"""
157
142
158
143
159
144
class ElementNotVisibleException (InvalidElementStateException ):
160
- """
161
- Thrown when an element is present on the DOM, but
162
- it is not visible, and so is not able to be interacted with.
145
+ """Thrown when an element is present on the DOM, but it is not visible, and
146
+ so is not able to be interacted with.
163
147
164
- Most commonly encountered when trying to click or read text
165
- of an element that is hidden from view.
148
+ Most commonly encountered when trying to click or read text of an
149
+ element that is hidden from view.
166
150
"""
167
151
168
152
169
153
class ElementNotInteractableException (InvalidElementStateException ):
170
- """
171
- Thrown when an element is present in the DOM but interactions
172
- with that element will hit another element due to paint order
173
- """
154
+ """Thrown when an element is present in the DOM but interactions with that
155
+ element will hit another element due to paint order."""
174
156
175
157
176
158
class ElementNotSelectableException (InvalidElementStateException ):
177
- """
178
- Thrown when trying to select an unselectable element.
159
+ """Thrown when trying to select an unselectable element.
179
160
180
161
For example, selecting a 'script' element.
181
162
"""
182
163
183
164
184
165
class InvalidCookieDomainException (WebDriverException ):
185
- """
186
- Thrown when attempting to add a cookie under a different domain
187
- than the current URL.
188
- """
166
+ """Thrown when attempting to add a cookie under a different domain than the
167
+ current URL."""
189
168
190
169
191
170
class UnableToSetCookieException (WebDriverException ):
192
- """
193
- Thrown when a driver fails to set a cookie.
194
- """
171
+ """Thrown when a driver fails to set a cookie."""
195
172
196
173
197
174
class TimeoutException (WebDriverException ):
198
- """
199
- Thrown when a command does not complete in enough time.
200
- """
175
+ """Thrown when a command does not complete in enough time."""
201
176
202
177
203
178
class MoveTargetOutOfBoundsException (WebDriverException ):
204
- """
205
- Thrown when the target provided to the `ActionsChains` move()
206
- method is invalid, i.e. out of document.
207
- """
179
+ """Thrown when the target provided to the `ActionsChains` move() method is
180
+ invalid, i.e. out of document."""
208
181
209
182
210
183
class UnexpectedTagNameException (WebDriverException ):
211
- """
212
- Thrown when a support class did not get an expected web element.
213
- """
184
+ """Thrown when a support class did not get an expected web element."""
214
185
215
186
216
187
class InvalidSelectorException (WebDriverException ):
217
- """
218
- Thrown when the selector which is used to find an element does not return
219
- a WebElement. Currently this only happens when the selector is an xpath
220
- expression and it is either syntactically invalid (i.e. it is not a
221
- xpath expression) or the expression does not select WebElements
222
- (e.g. "count(//input)").
188
+ """Thrown when the selector which is used to find an element does not
189
+ return a WebElement.
190
+
191
+ Currently this only happens when the selector is an xpath expression
192
+ and it is either syntactically invalid (i.e. it is not a xpath
193
+ expression) or the expression does not select WebElements (e.g.
194
+ "count(//input)").
223
195
"""
224
196
225
197
226
198
class ImeNotAvailableException (WebDriverException ):
227
- """
228
- Thrown when IME support is not available. This exception is thrown for every IME-related
229
- method call if IME support is not available on the machine.
199
+ """Thrown when IME support is not available.
200
+
201
+ This exception is thrown for every IME-related method call if IME
202
+ support is not available on the machine.
230
203
"""
231
204
232
205
233
206
class ImeActivationFailedException (WebDriverException ):
234
- """
235
- Thrown when activating an IME engine has failed.
236
- """
207
+ """Thrown when activating an IME engine has failed."""
237
208
238
209
239
210
class InvalidArgumentException (WebDriverException ):
240
- """
241
- The arguments passed to a command are either invalid or malformed.
242
- """
211
+ """The arguments passed to a command are either invalid or malformed."""
243
212
244
213
245
214
class JavascriptException (WebDriverException ):
246
- """
247
- An error occurred while executing JavaScript supplied by the user.
248
- """
215
+ """An error occurred while executing JavaScript supplied by the user."""
249
216
250
217
251
218
class NoSuchCookieException (WebDriverException ):
252
- """
253
- No cookie matching the given path name was found amongst the associated cookies of the
254
- current browsing context's active document.
255
- """
219
+ """No cookie matching the given path name was found amongst the associated
220
+ cookies of the current browsing context's active document."""
256
221
257
222
258
223
class ScreenshotException (WebDriverException ):
259
- """
260
- A screen capture was made impossible.
261
- """
224
+ """A screen capture was made impossible."""
262
225
263
226
264
227
class ElementClickInterceptedException (WebDriverException ):
265
- """
266
- The Element Click command could not be completed because the element receiving the events
267
- is obscuring the element that was requested to be clicked.
268
- """
228
+ """The Element Click command could not be completed because the element
229
+ receiving the events is obscuring the element that was requested to be
230
+ clicked."""
269
231
270
232
271
233
class InsecureCertificateException (WebDriverException ):
272
- """
273
- Navigation caused the user agent to hit a certificate warning, which is usually the result
274
- of an expired or invalid TLS certificate.
275
- """
234
+ """Navigation caused the user agent to hit a certificate warning, which is
235
+ usually the result of an expired or invalid TLS certificate."""
276
236
277
237
278
238
class InvalidCoordinatesException (WebDriverException ):
279
- """
280
- The coordinates provided to an interaction's operation are invalid.
281
- """
239
+ """The coordinates provided to an interaction's operation are invalid."""
282
240
283
241
284
242
class InvalidSessionIdException (WebDriverException ):
285
- """
286
- Occurs if the given session id is not in the list of active sessions, meaning the session
287
- either does not exist or that it's not active.
288
- """
243
+ """Occurs if the given session id is not in the list of active sessions,
244
+ meaning the session either does not exist or that it's not active."""
289
245
290
246
291
247
class SessionNotCreatedException (WebDriverException ):
292
- """
293
- A new session could not be created.
294
- """
248
+ """A new session could not be created."""
295
249
296
250
297
251
class UnknownMethodException (WebDriverException ):
298
- """
299
- The requested command matched a known URL but did not match any methods for that URL.
300
- """
252
+ """The requested command matched a known URL but did not match any methods
253
+ for that URL."""
301
254
302
255
303
256
class SeleniumManagerException (WebDriverException ):
0 commit comments