我正在使用 WebdriverIO 撰寫測驗用例,我注意到將值設定為輸入的唯一方法是使用setValue. 這從字面上將您擁有的整個值設定到輸入框。然而,我需要的是將字符一個一個地輸入到輸入中。我需要這樣做,因為我正在測驗的元素會在您鍵入時顯示 drodpown 選項。當我使用setvalue選項時不會出現,因為它只是將值復制到輸入中。
uj5u.com熱心網友回復:
您可以暫停輸入單個字符。(我在使用 webdriverIO 時遇到這個問題時的經驗)
前:
const value = "Auto- This note is created from automation at 09-05-2020 12:48 PM"
$(selector).setValue(value)
它在 UI 欄位中輸入了這樣的內容:
9-05-20is created from automAuto-This note tion at 020 12:48 PM
為了降低打字速度,我將字串的每個字符傳遞給 keys() 方法,并在這些字符傳遞之間暫停。
const value = "Auto- This note is created from automation at 09-05-2020 12:48 PM"
const arrValue = [...value]; // This is for converting string to charArray
for(let i = 0 ; i< arrValue.length; i ) {
browser.keys(arrValue[i] );
browser.pause(200); // .5 milisecond pause
輸出:
Auto- This note is created from automation at 09-05-2020 12:48 PM
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/357380.html
標籤:硒 测试 自动化测试 webdriver-io
