[英]How to double click an element on Selenium Webdriver using JavaScript for Safari
I'm facing a problem double clicking an element on Safari using Java / Webdriver 2.48. 我在使用Java / Webdriver 2.48双击Safari上的一个元素时遇到问题。
The tests are working fine on IE, Chrome, and Firefox but Actions are not supported on Safari. 这些测试在IE,Chrome和Firefox上运行正常,但Safari不支持“动作”。 Currently I'm doing something like this
目前我正在做这样的事情
executor.executeScript("arguments[0].dblclick();", element);
or 要么
executor.executeScript("arguments[0].dblclick;", element);
but is not working. 但不起作用。 Here is the error
这是错误
arguments[0].dblclick is not a function.
arguments [0] .dblclick不是函数。 (In 'arguments[0].dblclick()', 'arguments[0].dblclick' is undefined) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 35 milliseconds Build info: version: '2.48.0', revision: 'b7b081a4f1289f17e8ecd38bc67e137c2a12e34a', time: '2015-10-07 09:50:14' System info: host: 'MacBook-Pro.local', ip: '10.0.1.7', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11', java.version: '1.8.0_25' Driver info: org.openqa.selenium.safari.SafariDriver Capabilities [{browserName=safari, takesScreenshot=true, javascriptEnabled=true, version=9.0, cssSelectorsEnabled=true, platform=MAC, secureSsl=true}] Session ID: null
(在'arguments [0] .dblclick()'中,'arguments [0] .dblclick'未定义)(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:35毫秒构建信息:版本:'2.48 .0',修订版:'b7b081a4f1289f17e8ecd38bc67e137c2a12e34a',时间:'2015-10-07 09:50:14'系统信息:主机:'MacBook-Pro.local',ip:'10 .0.1.7',操作系统名称:' Mac OS X',os.arch:'x86_64',os.version:'10 .11',java.version:'1.8.0_25'驱动程序信息:org.openqa.selenium.safari.SafariDriver功能[{browserName = safari,takesScreenshot = true,javascriptEnabled = true,版本= 9.0,cssSelectorsEnabled = true,平台= MAC,secureSsl = true}]会话ID:null
I tried with dblclick and ondblclick but the double click was not executed, see the previous error. 我尝试使用dblclick和ondblclick,但没有执行双击,请参见上一个错误。
I was able to fix the issue using the following code 我可以使用以下代码解决此问题
It works on Safari 它适用于Safari
var event = new MouseEvent('dblclick', {
'view': window,
'bubbles': true,
'cancelable': true
});
document.querySelector("div[id='InProcessGrid']>div>table>tbody>tr.rowselected>td:nth-child(1)").dispatchEvent(event);
Here is more info about the issue 这是有关该问题的更多信息
https://github.com/webdriverio/webdriverio/issues/231 https://github.com/webdriverio/webdriverio/issues/231
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.