Skip to content

Commit

Permalink
Do some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmintz committed Dec 19, 2023
1 parent 0bb6ed6 commit c4b1408
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ def open(self, url):
try:
self.driver.get(url)
except Exception as e:
if (
if not hasattr(e, "msg") and hasattr(self.driver, "default_get"):
try:
self._check_browser()
time.sleep(0.4)
except Exception:
logging.debug("Browser crashed! Will open new browser!")
self.driver = self.get_new_driver()
self.driver.default_get(url)
elif (
"ERR_CONNECTION_TIMED_OUT" in e.msg
or "ERR_CONNECTION_CLOSED" in e.msg
or "ERR_CONNECTION_RESET" in e.msg
Expand Down Expand Up @@ -1018,7 +1026,7 @@ def add_text(self, selector, text, by="css selector", timeout=None):
# Use after "\t" or Keys.TAB to cycle through elements first.
self.click_active_element()
return
element = self.wait_for_element_visible(
element = self.wait_for_element_present(
selector, by=by, timeout=timeout
)
if (
Expand Down Expand Up @@ -1113,7 +1121,7 @@ def send_keys(self, selector, text, by="css selector", timeout=None):
def press_keys(self, selector, text, by="css selector", timeout=None):
"""Use send_keys() to press one key at a time."""
self.wait_for_ready_state_complete()
element = self.wait_for_element_clickable(
element = self.wait_for_element_present(
selector, by=by, timeout=timeout
)
if self.demo_mode:
Expand Down
4 changes: 2 additions & 2 deletions seleniumbase/fixtures/page_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ def send_keys(
driver, selector, text, by="css selector", timeout=settings.LARGE_TIMEOUT
):
selector, by = page_utils.recalculate_selector(selector, by)
element = wait_for_element_clickable(
element = wait_for_element_present(
driver, selector, by=by, timeout=timeout
)
if not text.endswith("\n"):
Expand All @@ -1597,7 +1597,7 @@ def press_keys(
driver, selector, text, by="css selector", timeout=settings.LARGE_TIMEOUT
):
selector, by = page_utils.recalculate_selector(selector, by)
element = wait_for_element_clickable(
element = wait_for_element_present(
driver, selector, by=by, timeout=timeout
)
if not text.endswith("\n"):
Expand Down

0 comments on commit c4b1408

Please sign in to comment.