-1

I have a case where I need to press "Enter" button to navigate on my web application (System under test).

I did achieved this using Selenium- Java using Robot class,

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);

Can I do the same using nightwatch js ?

3 Answers3

0

It's hard to say for certain without any details about why you're pressing enter or what pressing enter does on your application. As long as pressing enter is interacting with something inside the web browser (not a native OS window or application) then you should be able to use anything that is based on WebDriver API.

So I would say: Yes.

user2272115
  • 986
  • 1
  • 10
  • 22
0

You can try following way to press any key in nightwatch.js, i am pressing T and it is working superb!!

client.keys("t", function(done) {
    client.pause(5000);
    client.expect.element('#carousel_container').to.have.css('display').which.equals('block');
});

we are using above way because nightwatch.js Keys does not have any alphabet command in it's array, i have consoled and i haven't found any alphabet to press it.

Keys:
{ NULL: '',
  CANCEL: '',
  HELP: '',
  BACK_SPACE: '',
  TAB: '',
  CLEAR: '',
  RETURN: '',
  ENTER: '',
  SHIFT: '',
  CONTROL: '',
  ALT: '',
  PAUSE: '',
  ESCAPE: '',
  SPACE: '',
  PAGEUP: '',
  PAGEDOWN: '',
  END: '',
  HOME: '',
  LEFT_ARROW: '',
  UP_ARROW: '',
  RIGHT_ARROW: '',
  DOWN_ARROW: '',
  ARROW_LEFT: '',
  ARROW_UP: '',
  ARROW_RIGHT: '',
  ARROW_DOWN: '',
  INSERT: '',
  DELETE: '',
  SEMICOLON: '',
  EQUALS: '',
  NUMPAD0: '',
  NUMPAD1: '',
  NUMPAD2: '',
  NUMPAD3: '',
  NUMPAD4: '',
  NUMPAD5: '',
  NUMPAD6: '',
  NUMPAD7: '',
  NUMPAD8: '',
  NUMPAD9: '',
  MULTIPLY: '',
  ADD: '',
  SEPARATOR: '',
  SUBTRACT: '',
  DECIMAL: '',
  DIVIDE: '',
  F1: '',
  F2: '',
  F3: '',
  F4: '',
  F5: '',
  F6: '',
  F7: '',
  F8: '',
  F9: '',
  F10: '',
  F11: '',
  F12: '',
  COMMAND: '',
  META: '' 
},

You can press any key in above array easily like "client.keys(client.Keys.ENTER);".

Ashish-BeJovial
  • 1,829
  • 3
  • 38
  • 62
0

client.keys(client.Keys.ENTER);

Using the above code you can click an ENTER event on the form.