nightwatch: clearValue is not clearing the value

Hello, I have a box with a text value inside. So I want to call it using

.clearValue(element.durInput)

but it’s not clearing the value and so when I use .setValue it appends the new value instead of replacing. I wanted to instead use the code for keypress to press ctrl-a and then backspace to clear it. I’m using the code

browser.keys([browser.Keys.CONTROL, "a"])
browser.keys("8")

but I’m sure it’s wrong since it’s not working. Any idea how to make it work? Thanks in advance

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 25 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Clicking on the element prior to clearing does the trick for me.

browser
    .click(elementId)
    .clearValue(elementId)
    .setValue(elementId, 'A car floats in space');

I really suffered with this one today, so I share my solution since none of the other solutions worked for me for chrome & firefox:

`exports.command = function (fieldSelector) { const browserName = this.options.desiredCapabilities.browserName;

if (browserName === ‘chrome’) { this.getValue(fieldSelector, function (result) { this.setValue(fieldSelector, […(result.value || ‘’)].map(char => ‘\u0008’)); }); } else { this.clearValue(fieldSelector); }

return this; };`

This is a command to do one thing for chrome and other one for firefox

On the newest version of nightwatch and still having this issue, please fix

What was the resolution on this issue? I am seeing this issue but only when running the test against IE 11. Chrome and Firefox clear the field just fine.

We’ve also noticed that this problem only occurs in React applications. So, I wanted to ask here if there is someone who is facing the same issue with the clearValue command but not working on a React application.

When I use .setValue it appends the new value instead of replacing

In headless mode, setValue is working for me, but not with headless: false (nightwatch 2.4.1).

I have the exact same issue too - on chrome 87