Tuesday, October 25, 2011

Sending KeyStrokes

Sending key combination using Selenium-WebDriver

public void fn_sendKeys() {
String strURL;
WebElement txtGoogle;
WebDriver firefox=new FirefoxDriver();

strURL="www.google.com"
firefox.get(strURL);
txtGoogle=firefox.findElement(By.name("q"));

txtGoogle.sendKeys(Keys.CONTROL,"G");//Sending Ctrl+G key combination
}

No comments:

Post a Comment