@@ -1403,7 +1403,8 @@ def bring_to_front(self, selector, by=By.CSS_SELECTOR):
1403
1403
Other element would receive the click: ... } """
1404
1404
if page_utils .is_xpath_selector (selector ):
1405
1405
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 )
1407
1408
try :
1408
1409
selector = self .convert_to_css_selector (selector , by = by )
1409
1410
except Exception :
@@ -1439,7 +1440,7 @@ def highlight(self, selector, by=By.CSS_SELECTOR,
1439
1440
scroll - the option to scroll to the element first (Default: True)
1440
1441
"""
1441
1442
selector , by = self .__recalculate_selector (selector , by )
1442
- element = self .find_element (
1443
+ element = self .wait_for_element_visible (
1443
1444
selector , by = by , timeout = settings .SMALL_TIMEOUT )
1444
1445
if scroll :
1445
1446
self .__slow_scroll_to_element (element )
@@ -1725,7 +1726,7 @@ def choose_file(self, selector, file_path, by=By.CSS_SELECTOR,
1725
1726
def save_element_as_image_file (self , selector , file_name , folder = None ):
1726
1727
""" Take a screenshot of an element and save it as an image file.
1727
1728
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 )
1729
1730
element_png = element .screenshot_as_png
1730
1731
if len (file_name .split ('.' )[0 ]) < 1 :
1731
1732
raise Exception ("Error: file_name length must be > 0." )
@@ -1995,7 +1996,7 @@ def __select_option(self, dropdown_selector, option,
1995
1996
Defaults to "text" if option_by is unspecified or unknown. """
1996
1997
if page_utils .is_xpath_selector (dropdown_selector ):
1997
1998
dropdown_by = By .XPATH
1998
- element = self .find_element (
1999
+ element = self .wait_for_element_visible (
1999
2000
dropdown_selector , by = dropdown_by , timeout = timeout )
2000
2001
self .__demo_mode_highlight_if_active (dropdown_selector , dropdown_by )
2001
2002
pre_action_url = self .driver .current_url
@@ -2009,7 +2010,7 @@ def __select_option(self, dropdown_selector, option,
2009
2010
except (StaleElementReferenceException , ENI_Exception ):
2010
2011
self .wait_for_ready_state_complete ()
2011
2012
time .sleep (0.05 )
2012
- element = self .find_element (
2013
+ element = self .wait_for_element_visible (
2013
2014
dropdown_selector , by = dropdown_by , timeout = timeout )
2014
2015
if option_by == "index" :
2015
2016
Select (element ).select_by_index (option )
@@ -3063,7 +3064,7 @@ def __slow_scroll_to_element(self, element):
3063
3064
def __highlight_with_assert_success (
3064
3065
self , message , selector , by = By .CSS_SELECTOR ):
3065
3066
selector , by = self .__recalculate_selector (selector , by )
3066
- element = self .find_element (
3067
+ element = self .wait_for_element_visible (
3067
3068
selector , by = by , timeout = settings .SMALL_TIMEOUT )
3068
3069
try :
3069
3070
selector = self .convert_to_css_selector (selector , by = by )
0 commit comments