-1

cucumberjs not java

I have an angular component that uses a directive to change focus when x characters are entered into the input. I would like to verify in my cucumber tests.

1) does webElement.sendKeys trigger key events? I have tried sendKeys(1,9,9,9) but don'tknow if the events are being triggered

2) how can I listen for DOM events like paste, copy, keyup, etc... in a cucumber test?

I can't find any complete examples for cucumberjs and not sure the java examples really translate.

ed4becky
  • 1,488
  • 1
  • 17
  • 54
  • In my current project that I work on, we use WebDriverIO (https://webdriver.io/). I am not exactly sure with your syntax but yes, I think `webElement.sendKeys` will send keys to the input box. So try `webElement.sendKeys('hello');`. Your test can be, set focus on the first input, send the keys, expect this input not to have focus, expect the next input to have focus. I use WebDriverIO with Cucumber/Gherkin on top of it so for me WebDriverIO's API is simpler but I am sure it can be done with what you have as well. – AliF50 Mar 20 '20 at 02:21
  • I know sendkeys will update input box. The question is about what if any events get triggered. – ed4becky Mar 20 '20 at 16:50

1 Answers1

0

As far as I know, None of the End to End test automation tools like Protractor, WebdriverIO, NightwatchJS and CypressIO support this natively. Unit testing tools might have a solution for this and I found below info on Googling. Hope it is of some help to you.

How can I unit test an event listener on an input field?

Raju
  • 2,299
  • 2
  • 16
  • 19