Skip to content

Commit 9835426

Browse files
committed
Improve Safari automation compatibility
1 parent 4ed6d18 commit 9835426

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def test_anything(self):
4444
ElementClickInterceptedException as ECI_Exception,
4545
ElementNotInteractableException as ENI_Exception,
4646
MoveTargetOutOfBoundsException,
47+
NoSuchElementException,
4748
NoSuchWindowException,
4849
StaleElementReferenceException,
4950
WebDriverException,
@@ -364,6 +365,8 @@ def click(
364365
self.wait_for_angularjs(timeout=settings.MINI_TIMEOUT)
365366
if self.driver.current_url != pre_action_url:
366367
self.__ad_block_as_needed()
368+
if self.browser == "safari":
369+
time.sleep(0.02)
367370
if self.demo_mode:
368371
if self.driver.current_url != pre_action_url:
369372
self.__demo_mode_pause_if_active()
@@ -4866,14 +4869,26 @@ def choose_file(
48664869
if type(abs_path) is int or type(abs_path) is float:
48674870
abs_path = str(abs_path)
48684871
try:
4869-
element.send_keys(abs_path)
4872+
if self.browser == "safari":
4873+
try:
4874+
element.send_keys(abs_path)
4875+
except NoSuchElementException:
4876+
pass # May get this error on Safari even if upload works.
4877+
else:
4878+
element.send_keys(abs_path)
48704879
except (StaleElementReferenceException, ENI_Exception):
48714880
self.wait_for_ready_state_complete()
48724881
time.sleep(0.16)
48734882
element = self.wait_for_element_present(
48744883
selector, by=by, timeout=timeout
48754884
)
4876-
element.send_keys(abs_path)
4885+
if self.browser == "safari":
4886+
try:
4887+
element.send_keys(abs_path)
4888+
except NoSuchElementException:
4889+
pass # May get this error on Safari even if upload works.
4890+
else:
4891+
element.send_keys(abs_path)
48774892
if self.demo_mode:
48784893
if self.driver.current_url != pre_action_url:
48794894
self.__demo_mode_pause_if_active()

0 commit comments

Comments
 (0)