Skip to content

Commit 1172aa5

Browse files
committed
Add get_beautiful_soup() method to base_case
1 parent 870951e commit 1172aa5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,13 +1552,24 @@ def ad_block(self):
15521552
except Exception:
15531553
pass # Don't fail test if ad_blocking fails
15541554

1555+
@decorators.deprecated("Use re.escape() instead! It does what you want!")
15551556
def jq_format(self, code):
1556-
# DEPRECATED - Use re.escape() instead, which does the action you want.
1557+
# DEPRECATED - re.escape() already does that thing you want!
15571558
return js_utils._jq_format(code)
15581559

15591560
def get_domain_url(self, url):
15601561
return page_utils.get_domain_url(url)
15611562

1563+
def get_beautiful_soup(self, source=None):
1564+
""" BeautifulSoup is a toolkit for dissecting an HTML document
1565+
and extracting what you need. It's great for screen-scraping! """
1566+
from bs4 import BeautifulSoup
1567+
if not source:
1568+
self.wait_for_ready_state_complete()
1569+
source = self.get_page_source()
1570+
soup = BeautifulSoup(source, "html.parser")
1571+
return soup
1572+
15621573
def safe_execute_script(self, script):
15631574
""" When executing a script that contains a jQuery command,
15641575
it's important that the jQuery library has been loaded first.

0 commit comments

Comments
 (0)