Skip to content

Commit c230072

Browse files
committed
Use the new method for getting the BeautifulSoup soup
1 parent 552c545 commit c230072

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ def is_link_text_present(self, link_text):
196196
""" Returns True if the link text appears in the HTML of the page.
197197
The element doesn't need to be visible,
198198
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()
202200
html_links = soup.find_all('a')
203201
for html_link in html_links:
204202
if html_link.text.strip() == link_text.strip():
@@ -209,9 +207,7 @@ def get_link_attribute(self, link_text, attribute, hard_fail=True):
209207
""" Finds a link by link text and then returns the attribute's value.
210208
If the link text or attribute cannot be found, an exception will
211209
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()
215211
html_links = soup.find_all('a')
216212
for html_link in html_links:
217213
if html_link.text.strip() == link_text.strip():
@@ -340,8 +336,7 @@ def click_partial_link_text(self, partial_link_text,
340336
element = self.wait_for_partial_link_text(partial_link_text)
341337
element.click()
342338
return
343-
source = self.get_page_source()
344-
soup = BeautifulSoup(source, "html.parser")
339+
soup = self.get_beautiful_soup()
345340
html_links = soup.fetch('a')
346341
for html_link in html_links:
347342
if partial_link_text in html_link.text:
@@ -701,8 +696,7 @@ def is_element_in_an_iframe(self, selector, by=By.CSS_SELECTOR):
701696
selector, by = self.__recalculate_selector(selector, by)
702697
if self.is_element_present(selector, by=by):
703698
return False
704-
source = self.get_page_source()
705-
soup = BeautifulSoup(source, "html.parser")
699+
soup = self.get_beautiful_soup()
706700
iframe_list = soup.select('iframe')
707701
for iframe in iframe_list:
708702
iframe_identifier = None
@@ -727,8 +721,7 @@ def switch_to_frame_of_element(self, selector, by=By.CSS_SELECTOR):
727721
selector, by = self.__recalculate_selector(selector, by)
728722
if self.is_element_present(selector, by=by):
729723
return None
730-
source = self.get_page_source()
731-
soup = BeautifulSoup(source, "html.parser")
724+
soup = self.get_beautiful_soup()
732725
iframe_list = soup.select('iframe')
733726
for iframe in iframe_list:
734727
iframe_identifier = None
@@ -2570,8 +2563,7 @@ def __get_href_from_link_text(self, link_text, hard_fail=True):
25702563

25712564
def __click_dropdown_link_text(self, link_text, link_css):
25722565
""" 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()
25752567
drop_down_list = soup.select('[class*=dropdown]')
25762568
for item in soup.select('[class*=HeaderMenu]'):
25772569
drop_down_list.append(item)

0 commit comments

Comments
 (0)