guapo
guapo

Reputation: 1

Slowly sendkeys with c# selenium

Is it possible to write slowly one by one with selenium ? My code drv.FindElements(By.XPath("//input[@class='class id']"))[0].SendKeys(name); Is it possible to write the name slowly here example (n 1000ms , a 1000ms , m 1000ms , e 1000ms)

Upvotes: 0

Views: 585

Answers (1)

0x000000F4
0x000000F4

Reputation: 68

I have not tested it. I don't like to use Thread.Sleep(); because it freezes GUI.

public async Task SendKeysSlowly(int delay, string text, IWebElement element)
{     
    foreach(string str in text)
    {
        element.SendKeys(str);
        await Task.Delay(delay);
    }
}

usage;

await SendKeysSlowly(1000, "hello world", myelement);

Upvotes: 3

Related Questions