1515# specific language governing permissions and limitations
1616# under the License.
1717
18- """
19- Exceptions that may happen in all the webdriver code.
20- """
18+ """Exceptions that may happen in all the webdriver code."""
2119
2220from typing import Optional
2321from typing import Sequence
2422
2523
2624class WebDriverException (Exception ):
27- """
28- Base webdriver exception.
29- """
25+ """Base webdriver exception."""
3026
3127 def __init__ (
3228 self , msg : Optional [str ] = None , screen : Optional [str ] = None , stacktrace : Optional [Sequence [str ]] = None
@@ -47,32 +43,25 @@ def __str__(self) -> str:
4743
4844
4945class 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."""
5347
5448
5549class 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."""
5951
6052
6153class 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.
6455
6556 To find the current set of active window handles, you can get a list
6657 of the active window handles in the following way::
6758
6859 print driver.window_handles
69-
7060 """
7161
7262
7363class NoSuchElementException (WebDriverException ):
74- """
75- Thrown when element could not be found.
64+ """Thrown when element could not be found.
7665
7766 If you encounter this exception, you may want to check the following:
7867 * Check your selector used in your find_by...
@@ -83,25 +72,22 @@ class NoSuchElementException(WebDriverException):
8372
8473
8574class 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.
8876
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)
9281 """
9382
9483
9584class 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."""
10087
10188
10289class 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".
10591
10692 Stale means the element no longer appears on the DOM of the page.
10793
@@ -118,19 +104,19 @@ class StaleElementReferenceException(WebDriverException):
118104
119105
120106class 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.
123109
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.
125112 """
126113
127114
128115class UnexpectedAlertPresentException (WebDriverException ):
129- """
130- Thrown when an unexpected alert has appeared.
116+ """Thrown when an unexpected alert has appeared.
131117
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.
134120 """
135121
136122 def __init__ (
@@ -148,156 +134,123 @@ def __str__(self) -> str:
148134
149135
150136class NoAlertPresentException (WebDriverException ):
151- """
152- Thrown when switching to no presented alert.
137+ """Thrown when switching to no presented alert.
153138
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.
156141 """
157142
158143
159144class 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.
163147
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.
166150 """
167151
168152
169153class 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."""
174156
175157
176158class ElementNotSelectableException (InvalidElementStateException ):
177- """
178- Thrown when trying to select an unselectable element.
159+ """Thrown when trying to select an unselectable element.
179160
180161 For example, selecting a 'script' element.
181162 """
182163
183164
184165class 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."""
189168
190169
191170class UnableToSetCookieException (WebDriverException ):
192- """
193- Thrown when a driver fails to set a cookie.
194- """
171+ """Thrown when a driver fails to set a cookie."""
195172
196173
197174class 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."""
201176
202177
203178class 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."""
208181
209182
210183class 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."""
214185
215186
216187class 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)").
223195 """
224196
225197
226198class 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.
230203 """
231204
232205
233206class ImeActivationFailedException (WebDriverException ):
234- """
235- Thrown when activating an IME engine has failed.
236- """
207+ """Thrown when activating an IME engine has failed."""
237208
238209
239210class 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."""
243212
244213
245214class 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."""
249216
250217
251218class 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."""
256221
257222
258223class ScreenshotException (WebDriverException ):
259- """
260- A screen capture was made impossible.
261- """
224+ """A screen capture was made impossible."""
262225
263226
264227class 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."""
269231
270232
271233class 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."""
276236
277237
278238class 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."""
282240
283241
284242class 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."""
289245
290246
291247class SessionNotCreatedException (WebDriverException ):
292- """
293- A new session could not be created.
294- """
248+ """A new session could not be created."""
295249
296250
297251class 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."""
301254
302255
303256class SeleniumManagerException (WebDriverException ):
0 commit comments