[英]C# Selenium: How to send each character in sendkeys();
I have always found that sending keys to a web page text box has been fast.我一直发现将密钥发送到网页文本框的速度很快。 I need to do something where instead of the keys being instantly typed, I want each character to have a delay / sleep.
我需要做一些事情,而不是立即键入键,我希望每个角色都有延迟/睡眠。 Example:
例子:
That is what I currently need help with.这就是我目前需要帮助的。
You can use Thread.Sleep
after each send character.and you can change number 10 and use each number .您可以在每个发送字符后使用
Thread.Sleep
您可以更改数字 10 并使用每个数字。
string answer ="Apple";
char[] charArray = answer.ToCharArray();
for (int i = 0; i < charArray.Length; i++)
{
element.SendKeys(charArray[i].ToString());
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10));//10 is test
}
You can loop through the string that you want to send pausing however much time you'd like (1 second in this example) like this:您可以像这样循环播放要发送的字符串,但可以根据需要暂停多长时间(在本例中为 1 秒):
foreach (char letter in answer)
{
element.SendKeys(letter.ToString());
System.Threading.Thread.Sleep(1000);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.