gpt4 book ai didi

javascript - Selenium ,java,js "Exception in thread "主“org.openqa.selenium.JavascriptException : missing ) after argument list"

转载 作者:行者123 更新时间:2023-12-01 18:48:18 25 4
gpt4 key购买 nike

当我将以下代码放入 Chrome 的开发人员工具控制台时,它们工作正常。然而,当我将它们放入 Selenium 中时,我收到“参数列表后缺少 )”错误。我知道这可能意味着问题可能是由于语法不正确造成的,但我不确定如何或为什么会出现这种情况。 请注意,这些尝试是单独完成的

//Attempt 1
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript( "var evt = document.createEvent('MouseEvent');" +
"evt.initMouseEvent('mousedown', true, true, window, 0, 0, 0, 382, 290 , false, false, false, false, 0, null);" +
"var cb = document.getElementById('gameCanvas');"+
"cb.dispatchEvent(evt);"+
"setTimeout(function(){"+
"evt.initMouseEvent('mouseup', true, true, window, 0, 0, 0, 382, 290 false, false, false, false, 0, null);"+
"cb.dispatchEvent(evt);}, 100); };");

//Attempt 2
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript( "var evt = document.createEvent('MouseEvent');" +
"evt.initMouseEvent('mousedown', true, true, window, 0, 0, 0, 382, 290 , false, false, false, false, 0, null);" +
"var cb = document.getElementById('gameCanvas');"+
"cb.dispatchEvent(evt);"+
"evt.initMouseEvent('mouseup', true, true, window, 0, 0, 0, 382, 290 false, false, false, false, 0, null);"+
"cb.dispatchEvent(evt);");

最佳答案

In both of the attempts the second evt.initMouseEvent line lacks a comma between 290 and false. – Teemu 28 mins ago

还有一个额外的“};”在“100);”之后。

关于javascript - Selenium ,java,js "Exception in thread "主“org.openqa.selenium.JavascriptException : missing ) after argument list",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59777507/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com