KeyEvents in Selenium

import java.awt.event.KeyEvent;
public class KeyEventsExample extends DriverScript{


public static void main(String[] args) {

DefaultSelenium selenium = new DefaultSelenium("localhost",portno,"*firefox","url");
// TODO Auto-generated method stub
selenium.start();
selenium.open("http://www.google.com");
selenium.windowMaximize();
selenium.setCursorPosition("q", "1");
selenium.keyDownNative(Integer.toString(KeyEvent.VK_SHIFT));
selenium.keyPressNative(String.valueOf(KeyEvent.VK_D));
selenium.keyUpNative(Integer.toString(KeyEvent.VK_SHIFT));
//selenium.keyDownNative(Integer.toString(KeyEvent.VK_SHIFT));
selenium.keyPressNative(Integer.toString(KeyEvent.VK_SEMICOLON));
selenium.keyUpNative(Integer.toString(KeyEvent.VK_SHIFT));
selenium.keyPressNative(Integer.toString(KeyEvent.VK_SLASH));
selenium.keyPressNative(String.valueOf(KeyEvent.VK_S));
selenium.keyPressNative(String.valueOf(KeyEvent.VK_E));
selenium.keyPressNative(String.valueOf(KeyEvent.VK_L));
selenium.keyPressNative(String.valueOf(KeyEvent.VK_E));
selenium.keyPressNative(String.valueOf(KeyEvent.VK_N));

}

}

2 comments:


  1. Amazing, thanks a lot my friend, I was also siting like a your banner image when I was thrown into Selenium.When I started learning then I understood it has got really cool stuff.
    I can vouch webdriver has proved the best feature in Selenium framework.
    Thanks a lot for taking a time to share a wonderful article.

    Selenium Training in Velachery | Selenium Training Institute in Chennai

    ReplyDelete