网页执行js代码报错\Work\xbot-v5-uia\src\ShadowBot.UIAutomation.Provider\Common\IPC\IPCServiceInfo.cs:line 52
回答
收藏

网页执行js代码报错\Work\xbot-v5-uia\src\ShadowBot.UIAutomation.Provider\Common\IPC\IPCServiceInfo.cs:line 52

x
xuheng925
2023-10-07 22:22·浏览量:1750
x
xuheng925
发布于 2023-10-07 22:21更新于 2023-10-07 22:221750浏览

我打开某网页对象webpage后,需要在该网页上执行以下js代码(背景是要更新日期输入框 - 这个输入框是只读的,并且影刀现有的日期编辑节点试过了不太好用,所以只能用js。。。):

function updateDateBoxes(date) {
    var iframeWindow = document.getElementsByTagName('iframe')[1].contentWindow;
    iframeWindow.eval(`
        var beginDateElement = $("#beginDate");
        var endDateElement = $("#endDate");
        beginDateElement.datebox('setValue', '${date}');
        endDateElement.datebox('setValue', '${date}');
    `);
}
updateDateBoxes('loop_each_date');


但是执行到这一步时,报了以下错误,请高手帮忙看看

\Work\xbot-v5-uia\src\ShadowBot.UIAutomation.Provider\Common\IPC\IPCServiceInfo.cs:line 52
Traceback (most recent call last):
  File "C:\Program Files (x86)\ShadowBot\shadowbot-5.13.33\python\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files (x86)\ShadowBot\shadowbot-5.13.33\python\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files (x86)\ShadowBot\shadowbot-5.13.33\python\lib\site-packages\xbot_interpreter.py", line 94, in <module>
    main()
  File "C:\Program Files (x86)\ShadowBot\shadowbot-5.13.33\python\lib\site-packages\xbot_interpreter.py", line 55, in main
    mod.main(args)
  File "C:\Users\徐衡\AppData\Local\ShadowBot\users\35ec220e-4e8b-48a7-8838-61c6921240c8\apps\8d4bb7c3-eb77-40b1-b1e0-d9b60f442939\xbot_robot\main.py", line 123, in main
    web_js_result = xbot_visual.web.browser.execute_javascript(browser=webpage, element=None, argument="", code="function updateDateBoxes(date) {\r\n\r\n    var iframeWindow = document.getElementsByTagName('iframe')[1].contentWindow;\r\n\r\n    iframeWindow.eval(`\r\n        var beginDateElement = $(\"#beginDate\");\r\n        var endDateElement = $(\"#endDate\");\r\n\r\n        // Use the EasyUI datebox API to set the values\r\n        beginDateElement.datebox('setValue', '${date}');\r\n        endDateElement.datebox('setValue', '${date}');\r\n    `);\r\n}\r\n\r\nupdateDateBoxes('2023-09-30');", timeout="20", _block=("main", 64, "执行JS脚本"))
  File "<string>", line 89, in wrapper
  File "<string>", line 84, in wrapper
  File "<string>", line 132, in execute_javascript
  File "<string>", line 216, in execute_javascript
  File "<string>", line 764, in _invoke
  File "<string>", line 115, in execute
  File "<string>", line 88, in execute
xbot.errors.UIAError: Message:Uncaught SyntaxError: Unexpected identifier 'updateDateBoxes'
@ about:blank:15:0
Code:105,StackTrace:
   at s8uvQck1n7GBQkpGARQ.yPtS3ekNGxvGwvdVw4Y.inZkI8N20n(String  , Object  ) in D:\Work\xbot-v5-uia\src\ShadowBot.UIAutomation.Provider\UIAutomation\Web\CEF\CEFConnection.win.cs:line 84
   at FELirYoXetVbghOfFru.EDySsBokQiVVytv4lMA.cLnom3Bo27(String  , String  ) in D:\Work\xbot-v5-uia\src\ShadowBot.UIAutomation.Provider\UIAutomation\Web\CEF\CEFBrowser.win.cs:line 126
   at ShadowBot.UIAutomation.Provider.Service.Web.CEF.CEFBrowserService.ExecuteJavaScript(Int32 browserId, String code, String argument) in D:\Work\xbot-v5-uia\src\ShadowBot.UIAutomation.Provider\Service\Web\CEF\CEFBrowserService.win.cs:line 101
   at lambda_method131(Closure , k8qxV1b4PpcJXP7kDXp , Object[] )
   at sRHMsUbjx64dIDAgAYf.dG3WUNbq4Gx7QhRR58n.WKab68LKMw(k8qxV1b4PpcJXP7kDXp  , MLE4EeqSYAMVAZrosaQ  ) in D:\Work\xbot-v5-uia\src\ShadowBot.UIAutomation.Provider\Common\IPC\IPCActionInvoker.cs:line 63
   at SFTVKDbZuhy6rNZnKHe.gCq9PNbcOVEObh5k8uQ.ArvbQtVtAf(k8qxV1b4PpcJXP7kDXp  , e0LoPRqoTuxhdkArK9g  ) in D:\Work\xbot-v5-uia\src\ShadowBot.UIAutomation.Provider\Common\IPC\IPCActionInfo.cs:line 34
   at CQg1QsjLpob751TTBib.K6IQ1Sj4JOcgUbuCwAC.t6Mje6psNF(e0LoPRqoTuxhdkArK9g  ) in D:\Work\xbot-v5-uia\src\ShadowBot.UIAutomation.Provider\Common\IPC\IPCServiceInfo.cs:line 52


同样的代码我在chrome的开发者模式下执行就是有效的

收藏
全部回答1
最新
发布回答
回答