注入JavaScript代码段以触发“mouseover”和“mouseout”事件。适用于Chrome,Firefox和Safari(本地和远程)。
对于IE11,我可以验证它在控制台中是否有效。但是当试图自动化它时,抛出错误:
JavaScript error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 64 milliseconds Build info: version: '2.53.0', revision: '35ae25b',
time: '2016-03-15 17:00:58' System info: host: '185-129-68-90', ip: '185.129.68.90', os.name: 'windows',
os.arch: 'x86', os.version: '10.0',
java.version: '1.8.0_121' Driver info: org.openqa.selenium.ie.InternetExplorerDriver Capabilities
[{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal,
ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS,
nativeEvents=true, ie.ensureCleanSession=true, elementScrollBehavior=0, ie.browserCommandLineSwitches=,
requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=about:blank, takesScreenshot=true,
javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true,
unexpectedAlertBehaviour=dismiss}]
使用: WebdriverIO - 版本4.6.2
代码段:
hoverOnChart: function(chartID, index) {
browser.execute((chartID, index) => {
$(`${chartID} g.amcharts-graph-column:nth-child(${index})`).trigger("mouseover");
}, chartID, index);
}
注意:在上面的场景中,我试图将鼠标悬停在使用amcharts
JavaScript库创建的图表上。