Send Keys or Set Text

That’s fine. However, be aware you’re testing the browser’s functionality as much as you’re testing your AUT. (And let’s be honest, testing the browser is not your job!)

To help you make a decision (and this is on a test by test basis) ask yourself this question:

Is there any key-handling code hooked up to an event on the control in question? If yes, probably best to use sendKeys. Otherwise, really, who cares?

One more thing: be pragmatic. If you are writing a test script that is for some reason giving you trouble AND if at that point in your workflow a genuine HUMAN user does NOT have the same problem, ANY workaround you apply to get past the problem is absolutely fine. IOW, if your sendKeys is giving you hell on some weird control and users don’t see an issue, use Set. Again, who cares? But DO apply the question above FIRST.

Hope that made sense.

3 Likes