0

I can send a single key press in night-watch without a problem, but I need to press combination of them. For example UP_ARROW + SHIFT

Code from page objects.

this.sendKeys('@pmField', this.api.Keys.UP_ARROW+this.api.Keys.SHIFT)

This function just sends keys in a sequence. Firstly arrow up and then shift and I'm expecting that they would be pressed together as a combination.

Suhas Bachhav
  • 403
  • 1
  • 7
  • 28

2 Answers2

0
browser
  .keys(browser.Keys.CONTROL) // hold the control
  .click('#element') // click something
  .keys(browser.Keys.NULL) // release the control

This works properly in my tests when i need to click multiple elements while holding the control key. I think you can combine it with following key strokes instead of clicks. Hope this helps.

Skuubi80
  • 18
  • 4
0

As Skuubi80 states you can use browser.keys().

Take a look at the api doc and note this line...

Rather than the setValue, the modifiers are not released at the end of the call. The state of the modifier keys is kept between calls, so mouse interactions can be performed while modifier keys are depressed.

Keep in mind this does mean that you will need to call browser.keys('null') to 'un-press' the keys once done.

Hope that helps :)

Asoc
  • 51
  • 2