When using clearValue in different ways, the input content is not cleared at all. It has no effect on the content.
[...]
.setValue('#password', 'tooless')
.setValue('#password_repeat', 'tooless')
// Registration should not work with password <8 chars
.assert.attributeContains('button.btn-primary', 'disabled', 'true')
.clearValue('css selector', '#password_repeat')
.setValue('#password_repeat', 'thatsalongenoughpassword')
.pause(500)
// Registration should not work when passwords don't match
.assert.attributeContains('button.btn-primary', 'disabled', 'true')
.clearValue('css selector', '#password')
.setValue('#password', 'thatsalongenoughpassword')
.pause(500)
.click('button.btn-primary')
Following versions of clearValue I tested:
.clearValue({
selector: '#password'
})
.clearValue('#password');
But in all cases it will send toolessthatsalongenoughpassword what is wrong.
Also, for me setValue implicates that it will REPLACE the content not append, this took a lot of time to find that out.
| nightwatch --version | 1.3.7 |
| geckodriver | v1.16.2 |
EDIT: To be fair, I've only noticed this clearValue behavior on mac and linux, see below env info. I am not sure how it works on windows machines.
env info
Nightwatch:
version: 1.3.7
changelog: https://github.com/nightwatchjs/nightwatch/releases/tag/v1.3.7
System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 14.5.0 - ~/.nvm/versions/node/v14.5.0/bin/node
Yarn: 1.22.4 - ~/.nvm/versions/node/v14.5.0/bin/yarn
npm: 6.14.7 - ~/.nvm/versions/node/v14.5.0/bin/npm
Browsers:
Chrome: 85.0.4183.83
Edge: Not Found
Firefox: 78.0.2
Safari: 13.1.2
I've noticed the same behavior with clearValue. As a workaround for now, wrote a custom command to click the element, then send a number of BACK_SPACE keys to match the length of the element value. Sample
@zwbetz-gh is correct that you have to send a number of BACK_SPACE keys. This also makes some sense from a user point of view: a regular user in a regular browser does not have a clearValue command that Nightwatch is mimicking. Since a user would have to press back space to remove the text, it makes (some) sense that Nightwatch would have to do that, too.
Question out of curiosity: @mxk1011 , is the page that you are testing and having this issue with using React?
I encountered the exact same problem. I dealed with it and saw that a double send clearValue() can be used as a dirty workaround. I have no clue what the problem is causing and why the workaround works 馃 (MacOS, NW 1.3.4, Node 13.9.0)
This issue has been automatically marked as stale because it has not had any recent activity.
If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.