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

1k views Asked by At

I'm just wondering what the preferred way to preform a ctrl + click action in leadfoot is. In java I would have used the Actions class and used keyDown, but since we have moved to a JS based framework I'm a complete fish out of water!

I've seen in the api that there is a pressKeys function but it doesn't seem to do what we need. I've thought about using jQuery to do this but I would really rather keep it in the current framework.

Any help greatly appreciated.

Peter

2

There are 2 answers

4
Linh Nguyen On BEST ANSWER

You can use pressKeys, for example:

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

A good thing to remember about 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.

1
Harpreet Singh On

TheIntern/LeadFoot provides you a function execute. You can trigger any event from this function using 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);

})

To trigger keyevent follow these links:

jquery trigger ctrl + click

How to trigger key combo with jQuery