Skip to content

Commit 99373f6

Browse files
committed
Refactor base_case
1 parent c621493 commit 99373f6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,8 @@ def bring_to_front(self, selector, by=By.CSS_SELECTOR):
14031403
Other element would receive the click: ... } """
14041404
if page_utils.is_xpath_selector(selector):
14051405
by = By.XPATH
1406-
self.find_element(selector, by=by, timeout=settings.SMALL_TIMEOUT)
1406+
self.wait_for_element_visible(
1407+
selector, by=by, timeout=settings.SMALL_TIMEOUT)
14071408
try:
14081409
selector = self.convert_to_css_selector(selector, by=by)
14091410
except Exception:
@@ -1439,7 +1440,7 @@ def highlight(self, selector, by=By.CSS_SELECTOR,
14391440
scroll - the option to scroll to the element first (Default: True)
14401441
"""
14411442
selector, by = self.__recalculate_selector(selector, by)
1442-
element = self.find_element(
1443+
element = self.wait_for_element_visible(
14431444
selector, by=by, timeout=settings.SMALL_TIMEOUT)
14441445
if scroll:
14451446
self.__slow_scroll_to_element(element)
@@ -1725,7 +1726,7 @@ def choose_file(self, selector, file_path, by=By.CSS_SELECTOR,
17251726
def save_element_as_image_file(self, selector, file_name, folder=None):
17261727
""" Take a screenshot of an element and save it as an image file.
17271728
If no folder is specified, will save it to the current folder. """
1728-
element = self.find_element(selector)
1729+
element = self.wait_for_element_visible(selector)
17291730
element_png = element.screenshot_as_png
17301731
if len(file_name.split('.')[0]) < 1:
17311732
raise Exception("Error: file_name length must be > 0.")
@@ -1995,7 +1996,7 @@ def __select_option(self, dropdown_selector, option,
19951996
Defaults to "text" if option_by is unspecified or unknown. """
19961997
if page_utils.is_xpath_selector(dropdown_selector):
19971998
dropdown_by = By.XPATH
1998-
element = self.find_element(
1999+
element = self.wait_for_element_visible(
19992000
dropdown_selector, by=dropdown_by, timeout=timeout)
20002001
self.__demo_mode_highlight_if_active(dropdown_selector, dropdown_by)
20012002
pre_action_url = self.driver.current_url
@@ -2009,7 +2010,7 @@ def __select_option(self, dropdown_selector, option,
20092010
except (StaleElementReferenceException, ENI_Exception):
20102011
self.wait_for_ready_state_complete()
20112012
time.sleep(0.05)
2012-
element = self.find_element(
2013+
element = self.wait_for_element_visible(
20132014
dropdown_selector, by=dropdown_by, timeout=timeout)
20142015
if option_by == "index":
20152016
Select(element).select_by_index(option)
@@ -3063,7 +3064,7 @@ def __slow_scroll_to_element(self, element):
30633064
def __highlight_with_assert_success(
30643065
self, message, selector, by=By.CSS_SELECTOR):
30653066
selector, by = self.__recalculate_selector(selector, by)
3066-
element = self.find_element(
3067+
element = self.wait_for_element_visible(
30673068
selector, by=by, timeout=settings.SMALL_TIMEOUT)
30683069
try:
30693070
selector = self.convert_to_css_selector(selector, by=by)

0 commit comments

Comments
 (0)