i m using nightwatch testing framework to test some functionality of the <input />
, and it fails on a race issue.
What i need to test
- Add a value to the input text:
xxxx
. - press
backspace
4 times. - assert that the
input
has value''
.
But i get that the input
has value of xx
:
ERROR: Expected element <#inputElement> to have value equal: "" - expected "equal ''" but got: "xx"
"type 4 chars and use backspace to clear the input": browser => {
searchBox.waitForElementVisible("@input")
.click("@input")
.setValue("@input",'xxxx');
for (let i = 0; i < 4; i++) {
await browser.keys(browser.Keys.BACK_SPACE);
}
searchbox.expect.element("@input").value.to.equal("");
searchbox.click("@input");
searchbox.expect.element("@input").value.to.equal("");
browser.end();
},
This leads to the conclusion, that the for loop is executed before the input
gets cleared, and then moves forward to the assertion. I tried the same test with async/await
but i have the same error again. Do i miss something ?
I test it with async/await like so:
"type 4 chars and use backspace to clear the input": async browser => {
searchBox.waitForElementVisible("@input")
.click("@input")
.setValue("@input",'xxxx');
for (let i = 0; i < 4; i++) {
await browser.keys(browser.Keys.BACK_SPACE);
}
await searchbox.click("@input");
await searchbox.expect.element("@input").value.to.equal("");
await browser.end();
},
Any help is welcome.
Aucun commentaire:
Enregistrer un commentaire