Skip to content

Commit

Permalink
Show detailed JavaScript Error
Browse files Browse the repository at this point in the history
  • Loading branch information
naibo committed Oct 18, 2024
1 parent 081c493 commit 72529c0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ExecuteStage/easyspider_executestage.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,18 +705,20 @@ def execute_code(self, codeMode, code, max_wait_time, element=None, iframe=False
self.browser.set_script_timeout(max_wait_time)
try:
output = self.browser.execute_script(code)
except:
except Exception as e:
output = ""
self.recordLog("JavaScript execution failed")
self.print_and_log("执行下面的代码时出错:" + code, ",错误为:", str(e))
self.print_and_log("Error executing the following code:" + code, ", error is:", str(e))
elif int(codeMode) == 2:
self.recordLog("Execute JavaScript for element:" + code)
self.recordLog("对元素执行JavaScript:" + code)
self.browser.set_script_timeout(max_wait_time)
try:
output = self.browser.execute_script(code, element)
except:
except Exception as e:
output = ""
self.recordLog("JavaScript execution failed")
self.print_and_log("执行下面的代码时出错:" + code, ",错误为:", str(e))
self.print_and_log("Error executing the following code:" + code, ", error is:", str(e))
elif int(codeMode) == 5:
try:
code = readCode(code)
Expand All @@ -726,9 +728,9 @@ def execute_code(self, codeMode, code, max_wait_time, element=None, iframe=False
self.recordLog("执行下面的代码:" + code)
self.recordLog("Execute the following code:" + code)
except Exception as e:
self.print_and_log("执行下面的代码时出错:" + code, ",错误为:", e)
self.print_and_log("执行下面的代码时出错:" + code, ",错误为:", str(e))
self.print_and_log("Error executing the following code:" +
code, ", error is:", e)
code, ", error is:", str(e))
elif int(codeMode) == 6:
try:
code = readCode(code)
Expand Down

0 comments on commit 72529c0

Please sign in to comment.