@@ -196,9 +196,7 @@ def is_link_text_present(self, link_text):
196
196
""" Returns True if the link text appears in the HTML of the page.
197
197
The element doesn't need to be visible,
198
198
such as elements hidden inside a dropdown selection. """
199
- self .wait_for_ready_state_complete ()
200
- source = self .get_page_source ()
201
- soup = BeautifulSoup (source , "html.parser" )
199
+ soup = self .get_beautiful_soup ()
202
200
html_links = soup .find_all ('a' )
203
201
for html_link in html_links :
204
202
if html_link .text .strip () == link_text .strip ():
@@ -209,9 +207,7 @@ def get_link_attribute(self, link_text, attribute, hard_fail=True):
209
207
""" Finds a link by link text and then returns the attribute's value.
210
208
If the link text or attribute cannot be found, an exception will
211
209
get raised if hard_fail is True (otherwise None is returned). """
212
- self .wait_for_ready_state_complete ()
213
- source = self .get_page_source ()
214
- soup = BeautifulSoup (source , "html.parser" )
210
+ soup = self .get_beautiful_soup ()
215
211
html_links = soup .find_all ('a' )
216
212
for html_link in html_links :
217
213
if html_link .text .strip () == link_text .strip ():
@@ -340,8 +336,7 @@ def click_partial_link_text(self, partial_link_text,
340
336
element = self .wait_for_partial_link_text (partial_link_text )
341
337
element .click ()
342
338
return
343
- source = self .get_page_source ()
344
- soup = BeautifulSoup (source , "html.parser" )
339
+ soup = self .get_beautiful_soup ()
345
340
html_links = soup .fetch ('a' )
346
341
for html_link in html_links :
347
342
if partial_link_text in html_link .text :
@@ -701,8 +696,7 @@ def is_element_in_an_iframe(self, selector, by=By.CSS_SELECTOR):
701
696
selector , by = self .__recalculate_selector (selector , by )
702
697
if self .is_element_present (selector , by = by ):
703
698
return False
704
- source = self .get_page_source ()
705
- soup = BeautifulSoup (source , "html.parser" )
699
+ soup = self .get_beautiful_soup ()
706
700
iframe_list = soup .select ('iframe' )
707
701
for iframe in iframe_list :
708
702
iframe_identifier = None
@@ -727,8 +721,7 @@ def switch_to_frame_of_element(self, selector, by=By.CSS_SELECTOR):
727
721
selector , by = self .__recalculate_selector (selector , by )
728
722
if self .is_element_present (selector , by = by ):
729
723
return None
730
- source = self .get_page_source ()
731
- soup = BeautifulSoup (source , "html.parser" )
724
+ soup = self .get_beautiful_soup ()
732
725
iframe_list = soup .select ('iframe' )
733
726
for iframe in iframe_list :
734
727
iframe_identifier = None
@@ -2570,8 +2563,7 @@ def __get_href_from_link_text(self, link_text, hard_fail=True):
2570
2563
2571
2564
def __click_dropdown_link_text (self , link_text , link_css ):
2572
2565
""" When a link may be hidden under a dropdown menu, use this. """
2573
- source = self .get_page_source ()
2574
- soup = BeautifulSoup (source , "html.parser" )
2566
+ soup = self .get_beautiful_soup ()
2575
2567
drop_down_list = soup .select ('[class*=dropdown]' )
2576
2568
for item in soup .select ('[class*=HeaderMenu]' ):
2577
2569
drop_down_list .append (item )
0 commit comments