Injecting versus typing text into a field
We may want to override the intrinsic setValue()
command to populate a field:
await inputField.setValue(newValue);
The reason is that injecting a value into an element may not necessarily kick off any additional JavaScript code behind the element. This might also skip some formatting that the developers added when we inject the data. Alternatively, we could use addValue()
:
await inputField.addValue(newValue);
Now, we might be appending text into a field that already has text. What we want is a function that will first clear the field, if populated, and then type just as a user would – letter by letter followed by the Tab key to move out of the field.
This can be accomplished in our framework in two ways.
First, we set the focus on the element and sending keystrokes through the browser.keys()
method. Second, we send keys to the element directly with its AddValue()
method. This would be a backup approach being slightly...