Skip to content

Commit 9a2bcef

Browse files
committed
Make the execute_script() methods more flexible
1 parent 0137c52 commit 9a2bcef

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

help_docs/method_summary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ self.load_html_file(html_file, new_page=True)
157157

158158
self.open_html_file(html_file)
159159

160-
self.execute_script(script)
160+
self.execute_script(script, *args, **kwargs)
161161

162162
self.execute_async_script(script, timeout=None)
163163

164-
self.safe_execute_script(script)
164+
self.safe_execute_script(script, *args, **kwargs)
165165

166166
self.set_window_rect(x, y, width, height)
167167

seleniumbase/fixtures/base_case.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,27 +1804,27 @@ def open_html_file(self, html_file):
18041804
file_path = abs_path + "/%s" % html_file
18051805
self.open("file://" + file_path)
18061806

1807-
def execute_script(self, script):
1807+
def execute_script(self, script, *args, **kwargs):
18081808
self.__check_scope()
1809-
return self.driver.execute_script(script)
1809+
return self.driver.execute_script(script, *args, **kwargs)
18101810

18111811
def execute_async_script(self, script, timeout=None):
18121812
self.__check_scope()
18131813
if not timeout:
18141814
timeout = settings.EXTREME_TIMEOUT
18151815
return js_utils.execute_async_script(self.driver, script, timeout)
18161816

1817-
def safe_execute_script(self, script):
1817+
def safe_execute_script(self, script, *args, **kwargs):
18181818
""" When executing a script that contains a jQuery command,
18191819
it's important that the jQuery library has been loaded first.
18201820
This method will load jQuery if it wasn't already loaded. """
18211821
self.__check_scope()
18221822
try:
1823-
return self.execute_script(script)
1823+
return self.driver.execute_script(script, *args, **kwargs)
18241824
except Exception:
18251825
# The likely reason this fails is because: "jQuery is not defined"
18261826
self.activate_jquery() # It's a good thing we can define it here
1827-
return self.execute_script(script)
1827+
return self.driver.execute_script(script, *args, **kwargs)
18281828

18291829
def set_window_rect(self, x, y, width, height):
18301830
self.__check_scope()

0 commit comments

Comments
 (0)