0

I am working on nightwatch.js, i want to update existing data so i need to remove old date and need to set new data, i tried two way to get my result.

1) set empty text using following nightwatch function.

browser.setValue('.MyClass', 'text',' ');

2) here i tried to use backspace but unfortunately nightwatch.js api documentation is not so good, so i tried following with the help of this link but not worked.

client.keys([client.Keys.COMMAND, "Backspace", client.Keys.NULL]);

above code not pressed mouse backspace but append 'Backspace'.

If you have any best idea, please let me know.

Community
  • 1
  • 1
Ashish-BeJovial
  • 1,829
  • 3
  • 38
  • 62

3 Answers3

1

You can use .clearValue('selector') now :

http://nightwatchjs.org/api/clearValue.html

Ray
  • 1,539
  • 1
  • 14
  • 27
0

Check the nightwatch api for setValue http://nightwatchjs.org/api#setValue

browser.setValue('input[type=text]', 'nightwatch');

Check the class you are entering, i guess somehow nightwatch is not able to find your element.

Rakesh
  • 9
  • 2
  • i tried following ways client.setValue('input[type=textarea]', ' '); //it now worked client.setValue('input[type=textarea]', 'nightwatch'); //this is appanding text to existing – Ashish-BeJovial Feb 04 '16 at 09:22
  • i tried to used 'this' as well in-place of 'client' because i am performing this step under css.getAttribute(); function. – Ashish-BeJovial Feb 04 '16 at 09:24
0

What follows is not optimal, I am sure. Either of the following lines of code will work for removing the last character of the string currently in the input field. It's just setting a backspace; sometimes that's what's works.

.useXpath().setValue(selector, "\u0008") 
.useCss().setValue(selector, "\u0008")

If you get the string in the input field, then get the length of the string you can sent this command that many times to remove the text in the input field. I'm not including it here as a suggestion, more as a workaround.

QualiT
  • 1,934
  • 2
  • 18
  • 37