@@ -45,9 +45,15 @@ class MyTestClass(BaseCase):
45
45
from seleniumbase .fixtures import page_utils
46
46
from seleniumbase .fixtures import xpath_to_css
47
47
from selenium .common .exceptions import (StaleElementReferenceException ,
48
- ElementNotInteractableException ,
49
48
TimeoutException ,
50
49
WebDriverException )
50
+ from selenium .common import exceptions as selenium_exceptions
51
+ try :
52
+ # Selenium 3
53
+ ENI_Exception = selenium_exceptions .ElementNotInteractableException
54
+ except Exception :
55
+ # Selenium 2 (Keep compatibility with seleneium 2.53.6 if still being used)
56
+ ENI_Exception = selenium_exceptions .ElementNotSelectableException
51
57
from selenium .webdriver .remote .webdriver import WebDriver
52
58
from selenium .webdriver .common .by import By
53
59
from selenium .webdriver .common .keys import Keys
@@ -97,8 +103,7 @@ def click(self, selector, by=By.CSS_SELECTOR,
97
103
pre_action_url = self .driver .current_url
98
104
try :
99
105
element .click ()
100
- except (StaleElementReferenceException ,
101
- ElementNotInteractableException ):
106
+ except (StaleElementReferenceException , ENI_Exception ):
102
107
self .wait_for_ready_state_complete ()
103
108
time .sleep (0.05 )
104
109
element = page_actions .wait_for_element_visible (
@@ -129,8 +134,7 @@ def double_click(self, selector, by=By.CSS_SELECTOR,
129
134
actions .move_to_element (element )
130
135
actions .double_click (element )
131
136
actions .perform ()
132
- except (StaleElementReferenceException ,
133
- ElementNotInteractableException ):
137
+ except (StaleElementReferenceException , ENI_Exception ):
134
138
self .wait_for_ready_state_complete ()
135
139
time .sleep (0.05 )
136
140
element = page_actions .wait_for_element_visible (
@@ -194,8 +198,7 @@ def click_link_text(self, link_text, timeout=settings.SMALL_TIMEOUT):
194
198
pre_action_url = self .driver .current_url
195
199
try :
196
200
element .click ()
197
- except (StaleElementReferenceException ,
198
- ElementNotInteractableException ):
201
+ except (StaleElementReferenceException , ENI_Exception ):
199
202
self .wait_for_ready_state_complete ()
200
203
time .sleep (0.05 )
201
204
element = self .wait_for_link_text_visible (
@@ -251,8 +254,7 @@ def click_partial_link_text(self, partial_link_text,
251
254
pre_action_url = self .driver .current_url
252
255
try :
253
256
element .click ()
254
- except (StaleElementReferenceException ,
255
- ElementNotInteractableException ):
257
+ except (StaleElementReferenceException , ENI_Exception ):
256
258
self .wait_for_ready_state_complete ()
257
259
time .sleep (0.05 )
258
260
element = self .wait_for_partial_link_text (
@@ -278,8 +280,7 @@ def get_text(self, selector, by=By.CSS_SELECTOR,
278
280
self .driver , selector , by , timeout )
279
281
try :
280
282
element_text = element .text
281
- except (StaleElementReferenceException ,
282
- ElementNotInteractableException ):
283
+ except (StaleElementReferenceException , ENI_Exception ):
283
284
self .wait_for_ready_state_complete ()
284
285
time .sleep (0.06 )
285
286
element = page_actions .wait_for_element_visible (
@@ -299,8 +300,7 @@ def get_attribute(self, selector, attribute, by=By.CSS_SELECTOR,
299
300
self .driver , selector , by , timeout )
300
301
try :
301
302
attribute_value = element .get_attribute (attribute )
302
- except (StaleElementReferenceException ,
303
- ElementNotInteractableException ):
303
+ except (StaleElementReferenceException , ENI_Exception ):
304
304
self .wait_for_ready_state_complete ()
305
305
time .sleep (0.06 )
306
306
element = page_actions .wait_for_element_present (
@@ -361,8 +361,7 @@ def add_text(self, selector, new_value, by=By.CSS_SELECTOR,
361
361
element .send_keys (Keys .RETURN )
362
362
if settings .WAIT_FOR_RSC_ON_PAGE_LOADS :
363
363
self .wait_for_ready_state_complete ()
364
- except (StaleElementReferenceException ,
365
- ElementNotInteractableException ):
364
+ except (StaleElementReferenceException , ENI_Exception ):
366
365
self .wait_for_ready_state_complete ()
367
366
time .sleep (0.06 )
368
367
element = self .wait_for_element_visible (
@@ -411,8 +410,7 @@ def update_text_value(self, selector, new_value, by=By.CSS_SELECTOR,
411
410
self ._scroll_to_element (element )
412
411
try :
413
412
element .clear ()
414
- except (StaleElementReferenceException ,
415
- ElementNotInteractableException ):
413
+ except (StaleElementReferenceException , ENI_Exception ):
416
414
self .wait_for_ready_state_complete ()
417
415
time .sleep (0.06 )
418
416
element = self .wait_for_element_visible (
@@ -429,8 +427,7 @@ def update_text_value(self, selector, new_value, by=By.CSS_SELECTOR,
429
427
element .send_keys (Keys .RETURN )
430
428
if settings .WAIT_FOR_RSC_ON_PAGE_LOADS :
431
429
self .wait_for_ready_state_complete ()
432
- except (StaleElementReferenceException ,
433
- ElementNotInteractableException ):
430
+ except (StaleElementReferenceException , ENI_Exception ):
434
431
self .wait_for_ready_state_complete ()
435
432
time .sleep (0.06 )
436
433
element = self .wait_for_element_visible (
@@ -631,8 +628,7 @@ def scroll_to(self, selector, by=By.CSS_SELECTOR,
631
628
selector , by = by , timeout = timeout )
632
629
try :
633
630
self ._scroll_to_element (element )
634
- except (StaleElementReferenceException ,
635
- ElementNotInteractableException ):
631
+ except (StaleElementReferenceException , ENI_Exception ):
636
632
self .wait_for_ready_state_complete ()
637
633
time .sleep (0.05 )
638
634
element = self .wait_for_element_visible (
@@ -1274,8 +1270,7 @@ def _pick_select_option(self, dropdown_selector, option,
1274
1270
Select (element ).select_by_value (option )
1275
1271
else :
1276
1272
Select (element ).select_by_visible_text (option )
1277
- except (StaleElementReferenceException ,
1278
- ElementNotInteractableException ):
1273
+ except (StaleElementReferenceException , ENI_Exception ):
1279
1274
self .wait_for_ready_state_complete ()
1280
1275
time .sleep (0.05 )
1281
1276
element = self .find_element (
0 commit comments