-1

I am new to Nightwatch.js and WebDriver Protocol. During reading these documents, I am curious about the difference with .keys() and .elementIdValue().

In Nightwatch API Reference, the definitions are below:

  • .keys(): Send a sequence of key strokes to the active element...
  • .elementIdValue(): Scrolls into view the form control element and then sends the provided keys to the element...

They both "keyin" some texts into the specified editable element, so I cannot figure out what the main difference is.

Cythilya
  • 99
  • 1
  • 9

1 Answers1

0

The answer is in the documentation:

  • .keys(): Send a sequence of key strokes to the active element
  • .elementIdValue(): Scrolls into view the form control element and then sends the provided keys to the element

So there has to be a current active element when you want to use .keys(). .elementIdValue() is used to send keys (or get the value from an element) by providing an element id, the element doesn't have to be selected before calling this method. When you don't provide a second parameter, you can use this method to get the value of the element. You can't get the value using .keys()

Marcel
  • 1,443
  • 2
  • 14
  • 24