在 Intern.js Leadfoot 中,如何执行 CTRL 单击

In Intern.js Leadfoot, how do I preform a CTRL Click

我只是想知道在 leadfoot 中执行 ctrl + 单击操作的首选方法是什么。在 java 中,我会使用 Actions class 并使用 keyDown,但自从我们已经转向基于 JS 的框架后,我完全没有水了!

我在 api 中看到有一个 pressKeys 函数,但它似乎不能满足我们的需要。我考虑过使用 jQuery 来执行此操作,但我真的宁愿将其保留在当前框架中。

非常感谢任何帮助。

彼得

TheIntern/LeadFoot为您提供了一个功能execute。您可以使用 JS 从该函数触发任何事件。

.execute(function() {
    //You can even access window from here
    $("#someId").click() //example

    //or try something like this
    e = jQuery.Event("keydown");        
    e.which = 50;
    e.ctrlKey = true;
    $("input").trigger(e);

})

要触发 keyevent 请点击以下链接:

jquery trigger ctrl + click

How to trigger key combo with jQuery

您可以使用pressKeys,例如:

command.moveMouseTo(myBtn)
       .pressKeys(keys.CONTROL)
       .clickMouseButton()
       .pressKeys(keys.CONTROL)

关于 pressKeys (https://theintern.github.io/leadfoot/Command.html#pressKeys)

的一件好事

keys: The text to type in the remote environment. It is possible to type keys that do not have normal character representations (modifier keys, function keys, etc.) as well as keys that have two different representations on a typical US-ASCII keyboard (numpad keys); use the values from leadfoot/keys to type these special characters. Any modifier keys that are activated by this call will persist until they are deactivated. To deactivate a modifier key, type the same modifier key a second time, or send \uE000 ('NULL') to deactivate all currently active modifier keys.