如何让WebdriverIO在输入框中慢速输入

How to make WebdriverIO type slowly in an input box

我正在使用 WebdriverIO 编写测试用例,我注意到为输入设置值的唯一方法是使用 setValue。这从字面上设置了输入框的全部值。然而,我需要的是将字符一个一个地输入到输入中。我需要这样做,因为我正在测试的元素会在您键入时显示 drodpown 选项。当我使用 setvalue 时,选项不会出现,因为它只是将值复制到输入。

您可以输入带有停顿的单个字符。 (我在使用 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