[英]How can i use nightwatch with async/await functionality?
即時通訊使用夜視測試框架來測試<input />
一些功能,並在競賽問題上失敗。
xxxx
。 backspace
4次。 input
有值''
。 但我知道input
值為xx
:
錯誤 : 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();
},
這導致結論,for循環在input
被清除之前執行,然后前進到斷言。 我嘗試使用async/await
進行相同的測試,但我又async/await
了同樣的錯誤。 我錯過了什么嗎?
"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();
},
歡迎任何幫助。
你不需要await
第一行代碼嗎?
await searchBox.waitForElementVisible("@input")
.click("@input")
.setValue("@input",'xxxx');
我認為它與輸入的字符並行退回四次,並且在發送最后一個退格后輸入其中兩個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.