Skip to content

Commit 2a9bf1c

Browse files
committed
Add "set_content(html_string)" method
1 parent 16e5ee6 commit 2a9bf1c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

help_docs/method_summary.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ self.select_option_by_value(dropdown_selector, option,
155155

156156
self.load_html_string(html_string, new_page=True)
157157

158+
self.set_content(html_string, new_page=False)
159+
158160
self.load_html_file(html_file, new_page=True)
159161

160162
self.open_html_file(html_file)

seleniumbase/fixtures/base_case.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,12 +1853,17 @@ def load_html_string(self, html_string, new_page=True):
18531853
line = line.strip()
18541854
new_lines.append(line)
18551855
js_code = '\n'.join(new_lines)
1856+
js_code = re.escape(js_code)
18561857
js_utils.add_js_code(self.driver, js_code)
18571858
elif js_src:
18581859
js_utils.add_js_link(self.driver, js_src)
18591860
else:
18601861
pass
18611862

1863+
def set_content(self, html_string, new_page=False):
1864+
""" Same as load_html_string(), but "new_page" defaults to False. """
1865+
self.load_html_string(html_string, new_page=new_page)
1866+
18621867
def load_html_file(self, html_file, new_page=True):
18631868
""" Loads a local html file into the browser from a relative file path.
18641869
If new_page==True, the page will switch to: "data:text/html,"

0 commit comments

Comments
 (0)