Skip to content

Commit 23fe017

Browse files
committed
Optimize JavaScript calls that require the use of jQuery
1 parent a628ee5 commit 23fe017

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,12 +1817,9 @@ def safe_execute_script(self, script, *args, **kwargs):
18171817
it's important that the jQuery library has been loaded first.
18181818
This method will load jQuery if it wasn't already loaded. """
18191819
self.__check_scope()
1820-
try:
1821-
return self.driver.execute_script(script, *args, **kwargs)
1822-
except Exception:
1823-
# The likely reason this fails is because: "jQuery is not defined"
1824-
self.activate_jquery() # It's a good thing we can define it here
1825-
return self.driver.execute_script(script, *args, **kwargs)
1820+
if not js_utils.is_jquery_activated(self.driver):
1821+
self.activate_jquery()
1822+
return self.driver.execute_script(script, *args, **kwargs)
18261823

18271824
def set_window_rect(self, x, y, width, height):
18281825
self.__check_scope()

0 commit comments

Comments
 (0)