5

I'm doing some automation on a Java-based web page that needs to do some validation between entries, so I thought I'd just do a Thread.Sleep between each SendKeys.Send, but for some reason it just sleeps for 10 secs (10 x 1sec pauses) as it loads the page and then shoots through the whole form without pausing in between each keypress.

Anyone any ideas why it's doing this, or any suggestions for an alternative way of achieving a pause between sendkeys?

Thread.Sleep(1000);
SendKeys.Send("{TAB}");
Thread.Sleep(1000);
SendKeys.Send(strTEST);

this is on a browser_DocumentCompleted event

Gustavo Mori
  • 8,319
  • 3
  • 38
  • 52
rs82uk
  • 737
  • 2
  • 9
  • 23

1 Answers1

3

To pause, you want to use the SendWait function instead of SendKeys: http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.sendwait(v=VS.90).aspx

SendKeys queues all the keys up and processes them later, as you are seeing. SendWait processes them and returns.

Ed Bayiates
  • 11,060
  • 4
  • 43
  • 62