Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setValue() doesn't clear input before setting new value #1140

Closed
ghost opened this issue Mar 2, 2016 · 44 comments
Closed

setValue() doesn't clear input before setting new value #1140

ghost opened this issue Mar 2, 2016 · 44 comments

Comments

@ghost
Copy link

ghost commented Mar 2, 2016

In my test case I have a step where new value is set to a non empty input (with type number). According to webdriverIO API, the setValue method should clear an input at first and then should type a new value. But in my case, setValue appends new value to existing one.

I'm using webdriverIO 3.4.0 with Selenium standalone server 2.52.0 and Firefox 44.0.2. The forms in my application under test are created with React.js library.

@christian-bromann
Copy link
Member

Could you post the selenium logs of that part where you use setValue?

@ghost
Copy link
Author

ghost commented Mar 3, 2016

Sure, here it is that part of selenium log:

12:16:04.077 INFO - Done: [clear: 17 [[FirefoxDriver: firefox on WINDOWS (2009724f-387c-4e20-8dc2-92df612798a8)] -> xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]]]
12:16:04.081 INFO - Executing: [send keys: 17 [[FirefoxDriver: firefox on WINDOWS (2009724f-387c-4e20-8dc2-92df612798a8)] -> xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]], [5]])
12:16:04.104 INFO - Done: [clear: 18 [[FirefoxDriver: firefox on WINDOWS (2009724f-387c-4e20-8dc2-92df612798a8)] -> xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]]]
12:16:04.110 INFO - Executing: [send keys: 18 [[FirefoxDriver: firefox on WINDOWS (2009724f-387c-4e20-8dc2-92df612798a8)] -> xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]], [5]])
12:16:04.135 INFO - Done: [clear: 19 [[FirefoxDriver: firefox on WINDOWS (2009724f-387c-4e20-8dc2-92df612798a8)] -> xpath: (//button[.="List polecony priorytetowy"]/../..//input)[3]]]
12:16:04.140 INFO - Executing: [send keys: 19 [[FirefoxDriver: firefox on WINDOWS (2009724f-387c-4e20-8dc2-92df612798a8)] -> xpath: (//button[.="List polecony priorytetowy"]/../..//input)[3]], [1, 0]])

@ishristov
Copy link

I am seeing the same problem. The inputs are not cleared (not with setValue() and not with clearElement() either). New values are appended.

12:41:57.165 INFO - Executing: [find elements: By.cssSelector: input[name=email]])
12:41:57.183 INFO - Done: [find elements: By.cssSelector: input[name=email]]
12:41:57.191 INFO - Executing: [clear: 3 [[ChromeDriver: chrome on MAC (1f3151b777f3aaf6b39852c72fc62d1a)] -> css selector: input[name=email]]])
12:41:57.219 INFO - Done: [clear: 3 [[ChromeDriver: chrome on MAC (1f3151b777f3aaf6b39852c72fc62d1a)] -> css selector: input[name=email]]]
12:41:57.227 INFO - Executing: [send keys: 3 [[ChromeDriver: chrome on MAC (1f3151b777f3aaf6b39852c72fc62d1a)] -> css selector: input[name=email]], [t, e, s, t, @, t, e, s, t, ., t, e, s, t]])
12:41:57.295 INFO - Done: [send keys: 3 [[ChromeDriver: chrome on MAC (1f3151b777f3aaf6b39852c72fc62d1a)] -> css selector: input[name=email]], [t, e, s, t, @, t, e, s, t, ., t, e, s, t]]

I am using webdriverio 4.0.3 and mercury for rendering the html.

@christian-bromann
Copy link
Member

It seems that the command gets executed successful though. Seems to be a Chromedriver issue then.

@ifilatov
Copy link

Faced the same problem. Input was not cleared with neither clearElement() nor setValue().

However, it starts working for me when I click the input or write something just before clearing (i'm using cucumberjs - and for some strange reason it does not work when I click/write in the same step, but works fine if I do this in previous step).

P.S. I'm using selenium: "2.48.2", chromedriver: "2.20", webdriverio: "2.4.5". ReactJS.

@christian-bromann
Copy link
Member

Could you update the selenium standalone server and try again?

@pi4r0n
Copy link

pi4r0n commented Apr 12, 2016

@adolatowska I have just run simple test (see below) with the same webdriverio version, same selenium standalone server, but different FF (45.0.1) and it works fine for me. FYI @christian-bromann

var webdriverio = require('../webdriverio');
var options = {
    desiredCapabilities: {
        browserName: 'firefox'
    }
};

webdriverio
    .remote(options)
    .init()
    .url('http://www.google.co.uk')
    .setValue('#lst-ib', 'test')
    .pause(5000)
    .setValue('#lst-ib', 'arek')
    .pause(5000)
    .end();

Selenoum Logs below

14:05:56.883 INFO - Selenium Server is up and running
14:06:03.154 INFO - Executing: [new session: Capabilities [{rotatable=true, locationContextEnabled=true, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@6de9b74d, browserName=firefox, javascriptEnabled=true, handlesAlerts=true, version=, platform=ANY, requestOrigins={name=webdriverio, version=3.4.0, url=http://webdriver.io}}]])
14:06:03.171 INFO - Creating a new session for Capabilities [{rotatable=true, locationContextEnabled=true, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@6de9b74d, browserName=firefox, javascriptEnabled=true, handlesAlerts=true, version=, platform=ANY, requestOrigins={name=webdriverio, version=3.4.0, url=http://webdriver.io}}]
14:06:06.831 INFO - Done: [new session: Capabilities [{rotatable=true, locationContextEnabled=true, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@6de9b74d, browserName=firefox, javascriptEnabled=true, handlesAlerts=true, version=, platform=ANY, requestOrigins={name=webdriverio, version=3.4.0, url=http://webdriver.io}}]]
14:06:06.852 INFO - Executing: [get: http://www.google.co.uk])
14:06:08.377 INFO - Done: [get: http://www.google.co.uk]
14:06:08.410 INFO - Executing: [find elements: By.id: lst-ib])
14:06:08.514 INFO - Done: [find elements: By.id: lst-ib]
14:06:08.530 INFO - Executing: [clear: 0 [[FirefoxDriver: firefox on MAC (5649de47-170c-d74d-b813-018cfa7da030)] -> id: lst-ib]])
14:06:08.623 INFO - Done: [clear: 0 [[FirefoxDriver: firefox on MAC (5649de47-170c-d74d-b813-018cfa7da030)] -> id: lst-ib]]
14:06:08.633 INFO - Executing: [send keys: 0 [[FirefoxDriver: firefox on MAC (5649de47-170c-d74d-b813-018cfa7da030)] -> id: lst-ib], [t, e, s, t]])
14:06:08.716 INFO - Done: [send keys: 0 [[FirefoxDriver: firefox on MAC (5649de47-170c-d74d-b813-018cfa7da030)] -> id: lst-ib], [t, e, s, t]]
14:06:13.729 INFO - Executing: [find elements: By.id: lst-ib])
14:06:13.741 INFO - Done: [find elements: By.id: lst-ib]
14:06:13.750 INFO - Executing: [clear: 0 [[FirefoxDriver: firefox on MAC (5649de47-170c-d74d-b813-018cfa7da030)] -> id: lst-ib]])
14:06:13.780 INFO - Done: [clear: 0 [[FirefoxDriver: firefox on MAC (5649de47-170c-d74d-b813-018cfa7da030)] -> id: lst-ib]]
14:06:13.787 INFO - Executing: [send keys: 0 [[FirefoxDriver: firefox on MAC (5649de47-170c-d74d-b813-018cfa7da030)] -> id: lst-ib], [a, r, e, k]])
14:06:13.851 INFO - Done: [send keys: 0 [[FirefoxDriver: firefox on MAC (5649de47-170c-d74d-b813-018cfa7da030)] -> id: lst-ib], [a, r, e, k]]
14:06:18.861 INFO - Executing: [delete session: f39e1174-0b7a-42b2-9d9d-1ac3505416f8])
14:06:19.596 INFO - Done: [delete session: f39e1174-0b7a-42b2-9d9d-1ac3505416f8]

@ghost
Copy link
Author

ghost commented Apr 12, 2016

I've tested again with Selenium Standalone version 2.53.0 and both FF versions: 45.0.1 and 45.0.2. Situation is the same. Here is Selenium log from run on FF v.45.0.1:


> 19:26:55.659 INFO - Executing: [clear: 22 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]]])
> 19:26:55.664 INFO - Done: [find elements: By.xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]]
> 19:26:55.671 INFO - Executing: [clear: 23 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]]])
> 19:26:55.677 INFO - Done: [find elements: By.xpath: (//button[.="List polecony priorytetowy"]/../..//input)[3]]
> 19:26:55.684 INFO - Executing: [clear: 24 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="List polecony priorytetowy"]/../..//input)[3]]])
> 19:26:55.700 INFO - Done: [clear: 22 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]]]
> 19:26:55.704 INFO - Executing: [send keys: 22 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]], [5]])
> 19:26:55.721 INFO - Done: [clear: 23 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]]]
> 19:26:55.726 INFO - Executing: [send keys: 23 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]], [5]])
> 19:26:55.741 INFO - Done: [clear: 24 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="List polecony prioryteto
> wy"]/../..//input)[3]]]
> 19:26:55.745 INFO - Executing: [send keys: 24 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="List polecony priorytetowy"]/../..//input)[3]], [1, 0]])
> 19:26:55.780 INFO - Done: [send keys: 22 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]], [5]]
> 19:26:55.814 INFO - Done: [send keys: 23 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]], [5]]
> 19:26:55.859 INFO - Done: [send keys: 24 [[FirefoxDriver: firefox on WINDOWS (c9c978bb-acc5-4693-a830-5676e4c0b35d)] -> xpath: (//button[.="List polecony priorytetowy"]/../..//input)[3]], [1, 0]]

and here is log from run on FF v. 45.0.2:


> 19:31:35.154 INFO - Executing: [clear: 22 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="List polecony priorytetowy"]/../..//input)[3]]])
> 19:31:35.160 INFO - Done: [find elements: By.xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]]
> 19:31:35.165 INFO - Executing: [clear: 23 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]]])
> 19:31:35.176 INFO - Done: [find elements: By.xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]]
> 19:31:35.181 INFO - Executing: [clear: 24 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]]])
> 19:31:35.199 INFO - Done: [clear: 22 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="List polecony priorytetowy"]/../..//input)[3]]]
> 19:31:35.204 INFO - Executing: [send keys: 22 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="List polecony priorytetowy"]/../..//input)[3]], [1, 0]])
> 19:31:35.219 INFO - Done: [clear: 23 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]]]
> 19:31:35.223 INFO - Executing: [send keys: 23 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]], [5]])
> 19:31:35.239 INFO - Done: [clear: 24 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]]]
> 19:31:35.244 INFO - Executing: [send keys: 24 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]], [5]])
> 19:31:35.298 INFO - Done: [send keys: 22 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="List polecony priorytetowy"]/../..//input)[3]], [1, 0]]
> 19:31:35.337 INFO - Done: [send keys: 23 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="List polecony ekonomiczny"]/../..//input)[3]], [5]]
> 19:31:35.372 INFO - Done: [send keys: 24 [[FirefoxDriver: firefox on WINDOWS (a1c5eedb-cbcb-40af-8c64-142651c20683)] -> xpath: (//button[.="Przesy?ka kurierska"]/../..//input)[3]], [5]]

@pi4r0n
Copy link

pi4r0n commented Apr 13, 2016

@adolatowska / @christian-bromann is it just me or "clear" send to (//button[.="Przesy?ka kurierska"]/../..//input)[3]]]) but "send keys" to (//button[.="Przesy?ka kurierska"]/../..//input)[3]]

Notice the extra " ] " in clear command at the end. It would explain, why its not clearing the values.

@christian-bromann
Copy link
Member

@adolatowska can you try to use a different selector?

@christian-bromann
Copy link
Member

Closing due to inactivity. I am happy to open this again, if this is still valid.

@mikhailpractice
Copy link

I also have the same issue with FF 47-49

@jkwaldrip
Copy link

I am having the same problem with both Firefox 53.0.2 and Chrome 58.0.3029.110 and selenium-standalone 6.4.1. I'm testing against a React app, if that helps at all.

@jkwaldrip
Copy link

I'm adding a resolution here and on #891 for the workaround I used. It looks like our React DOM isn't updating whenever an element is cleared with .clearElement() and then set again with .setValue(), so I had to backspace out the field one character at a time:

let x = browser.getValue(selector);
for (let i = 0; i < x.length; i++) { browser.setValue(selector, "\uE003").pause(100); };
browser.setValue(selector, newValue);

@swetashahi
Copy link

@jkwaldrip This workaround didn't work for me. We use react-redux for our front end and using setValue the value is always appended even if I clear the field using clearElement(). or with backspaces as given in your code above.Any other steps I can try?

@sbukke1
Copy link

sbukke1 commented Aug 3, 2018

Has there been any solution yet. I am still seeing the same issue. Here is my configuration

"wdio-chromedriver-service": "^0.1.2",
"webdriverio": "^4.8.0"

selenium-server-standalone-2.53.1.jar

@MartinX3
Copy link

Same issue here.
Selenium Server 3.14.0
Chromedriver 2.41

@2hansen
Copy link

2hansen commented Oct 25, 2018

Same issue re-introduced here after upgrading to Chromedriver 2.43 - now have to rely on @jkwaldrip's suggestion with backspacing.

@MartinX3
Copy link

MartinX3 commented Oct 25, 2018

Please try this, it worked for me
We first need to put the focus on the element, then clear it and then write stuff on it.

.click('input[aria-label=Login]') // Workaround to make .clearValue() possible.
.clearValue('input[aria-label=Login]') // Without clearValue() the value would be appended.
.setValue('input[aria-label=Login]', 'new_value')

@2hansen
Copy link

2hansen commented Oct 25, 2018

That was what I did until today, where I updated to latest Chromedriver, and it stopped working.

@MartinX3
Copy link

MartinX3 commented Nov 15, 2018

I can confirm it.
Please reopen the bug report.

@christian-bromann
Copy link
Member

@MartinX3 can you prove that this bug is WebdriverIO related? setValue hasn't changed within the last time so it seems like that Chrome introduced this regression.

@MartinX3
Copy link

MartinX3 commented Nov 15, 2018

Oh, can you help us by providing a link where to put this bug request?

I continue my selenium work next week.

@bob-laz
Copy link

bob-laz commented Dec 20, 2018

In case others are running into this issue, here is the solution I found:

let valueLength = browser.getValue(id).length
let backSpaces = new Array(valueLength).fill('Backspace')
browser.setValue(id, backSpaces)

The solution @jkwaldrip offered worked for me but it was very slow. This backspaces as fast as normal typing.

Can anyone confirm if this is indeed a chromedriver issue and how they determined that?

henrywang added a commit to henrywang/welder-web that referenced this issue Jan 8, 2019
martinpitt pushed a commit to osbuild/cockpit-composer that referenced this issue Jan 8, 2019
@stoneCC
Copy link

stoneCC commented Feb 15, 2019

i can found good solution.so .....i did it

 browser.addCommand("clearValue2", async function () {
            let valueLength = this.getValue().length
            let backSpaces = new Array(valueLength).fill('Backspace')
            this.setValue(backSpaces)

        }, true);
        browser.addCommand("setValue2", async function (val) {
            this.clearValue2();
            this.setValue(val)
        }, true);

@NBukuri
Copy link

NBukuri commented Jun 27, 2019

Same issue for:

"webdriverio": "5.7.15"

If you use:

selector.click()
selector.clearValue()
selector.setValue()

clearValue() is also ignored and you got the same problem.

To handle this problem, I found this solution and it works for me:

selector.doubleClick() //selects the text written in the input
browser.keys("Delete") //removes old value
selector.setValue() //sets new Value

jkozol pushed a commit to jkozol/welder-web that referenced this issue Jul 30, 2019
@Rajendiransivaprasath
Copy link

Rajendiransivaprasath commented Jul 31, 2019

1. in WebdriverIO v4, i tried to edit the text field by clear text (which contains special charactes like @, +, _) in text field by below following step. Eventhough it was not successful.

example: text=> abc+1234@gmail.com

step1:browser.clearElement(selector);

step2:browser.execute(function () {
            document.querySelector(>>>Cssselector<<<).value="";
        });

step3: browser.doubleClick(selector);
       browser.keys("Delete");

step4: browser.click(selector);
       browser.keys(['Meta',a]);
       browser.keys('Meta');
       browser.keys('Delete');

Note: below step is resolved this issue.

var count= browser.getAttribute(selector, value).length;
for (var i=0;i<count;i++)
{
if (browser.getAttribute(selector, value)=='')
break;
}
else
{
browser.doubleClick(selector);
browser.keys("Delete");
}
browser.pause(200);

// it will clear your text field easily.

Note: You can add new text in that text field.

@ghost
Copy link

ghost commented Aug 28, 2019

Just want to leave my two cents on this since the stuff above never worked. I made a utility function and passed in the element ( with TypeScript ).

export const deleteValue = async (browser: TestBrowser, selector: WebdriverIOAsync.Element) => {
    const value = await selector.getValue()
    const count = value.length
    for (var i=0;i<count;i++) {
        await selector.click();
        await browser.keys(['Meta', 'a']);
        await browser.keys(['Backspace']);
    }
    /*Modifier like Ctrl, Shift, Alt and Meta will stay pressed so you need to trigger them again to release them.*/
    await browser.keys(['Meta', 'a']);
    await browser.pause(200);
}

and I pass in like so...

const nameInput = await browser.$(`input[name=name]`);
await deleteValue(browser, nameInput);
await nameInput.setValue('John Doe');

@defusioner
Copy link

Getting the same issue here. When there is a value set to the input, clear function fails (no matter if the focus is set on the input). But if there is no default value and we type AND then clear, this works.

@defusioner
Copy link

@NBukuri your solution only works for inputs that do not contain special characters.

@Rajendiransivaprasath
Copy link

@defusiner
for special character things, try to get the length of that particular input field. apply loop to delete by double click on text field until text==""

var count= browser.getAttribute(selector, value).length;
for (var i=0;i<count;i++)
{
if (browser.getAttribute(selector, value)=='')
break;
}
else
{
browser.doubleClick(selector);
browser.keys("Delete");
}
browser.pause(200);

now send input value to corresponding text field.
this.inputfield.setValue(inputValue)

@defusioner
Copy link

@Rajendiransivaprasath

We've done exactly like that. Just wanted to mention that the double click does not work when there is more than 1 word or special characters in the input.

@wannadream
Copy link

wannadream commented Nov 1, 2019

I struggled with this for a while and write an awkward solution.

function clearInputValue(inputElement) { while (inputElement.getValue() !== '') { inputElement.doubleClick(); browser.keys('Delete'); inputElement.clearValue(); } }

@nareshnavinash
Copy link

When I run the tests in my Mac (local) clearValue() is working fine, but when the same tests are run in the Linux Docker environment (circleci/node:10-buster-browsers-legacy), I need to use the workaround which @bob-laz mentioned. Could be better if the same is fixed for Linux environment too.

@LilyGist
Copy link

LilyGist commented Jul 2, 2021

I was having this issue on a React frontend, clearValue() wasn't working either, but I was able to get it to work by first clicking the field and then using browser.execute(), like this:

selector.click();
browser.execute(s => {
    s.value = null;
},selector);
selector.setValue('value');

I also had the backspace approach working like this, but the other way seemed a little simpler:

const selectorValue = selector.getValue();
const backSpaces = new Array(selectorValue.length).fill('Backspace');
selector.setValue(backSpaces);
selector.setValue('value');

@DivyaVengada
Copy link

DivyaVengada commented Jul 6, 2021

This issue still persists in "wdio-chromedriver-service": "^6.0.3" in windows chrome Version 91.0.4472.124

@praveendvd
Copy link
Contributor

This issue still persists in "wdio-chromedriver-service": "^6.0.3" in windows chrome Version 91.0.4472.124

$(selector).clearValue() use clear value first before setvalue?

@DivyaVengada
Copy link

yes I have used clearValue and then setValue, but no luck :/

@praveendvd
Copy link
Contributor

any example for reproducing this issue

@josetaveiragomes
Copy link

This issue is still happening with me:
"wdio-chromedriver-service": "^7.3.2"
Windows Chrome Version: 100.0.4896.127

The setValue() method is only appending (not replacing) and the clearValue() method does not clear the input.
The workaround from @NBukuri works great so I am going with it while the issue persists.

@munishusa
Copy link

I am too, Still facing this issue.

I tried both :

(1) await browser.elementClear('#addressLine1');
(2) await input.clearValue(); Where 'input' is object of findElement();

@VikingTristan
Copy link

Also experienced this today and piggybacked on the backspace solutions and ended up with new command:

browser.addCommand("clearAndSetValue", async function (newValue) {
    const oldValue = await this.getValue();
    if(oldValue) {
        const backspaces = new Array(oldValue.length).fill("Backspace");
        await this.setValue(backspaces);
    }

    await expect(this).toHaveValue("");
    await this.setValue(newValue);
    await expect(this).toHaveValue(newValue);
});

@blackraspberryyy
Copy link

I tried the ctrl+a approach for selecting the whole text, then pressing backspace. This works for me.

import { Key } from 'webdriverio';

// interact with the selector
await searchBox.doubleClick();

 // select all text
await browser.keys([Key.Ctrl, 'a']);

// unpress ctrl key
await browser.keys([Key.Ctrl]);

// presses backspace
await browser.keys(Key.Delete); 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests