My Blog List

Wednesday, October 19, 2011

Pass keys in Selenium Tests


Hi all,

Here is the simple way to pass any KeyBoard keys to selenium. You can use below methods for your required purpose.

sel.keyDownNative(java.awt.event.KeyEvent.VK_SHIFT + "");  //To keep pressing a key
sel.keyPressNative(java.awt.event.KeyEvent.VK_F1 + "");  //To just type a key
sel.keyUpNative(java.awt.event.KeyEvent.VK_SHIFT + ""); //To Release a key being in pressed state

For WebDriver instance, just pass using

driver.sendKeys()

1 comment:

  1. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete