1package com.automation.selenium.keyboard;2import org.openqa.selenium.By;3import org.openqa.selenium.Keys;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.WebElement;6import org.openqa.selenium.chrome.ChromeDriver;7import org.openqa.selenium.interactions.Actions;8public class Example1 {9 public static void main(String[] args) {10 WebDriver driver = null;11 try {12 System.setProperty("webdriver.chrome.driver", "D:\\Selenium\\SeleniumJars\\chromedriver.exe");13 driver = new ChromeDriver();14 driver.manage().window().maximize();15 WebElement searchBox = driver.findElement(By.name("q"));16 searchBox.sendKeys("Selenium");17 Actions actions = new Actions(driver);18 actions.keyDown(searchBox, Keys.SHIFT).sendKeys("webdriver").keyUp(Keys.SHIFT).perform();19 actions.sendKeys(Keys.ENTER).perform();20 Thread.sleep(2000);21 driver.navigate().back();22 Thread.sleep(2000);23 actions.sendKeys(Keys.F5).perform();24 Thread.sleep(2000);25 actions.sendKeys(Keys.CONTROL, "t").perform();26 Thread.sleep(2000);27 actions.sendKeys(Keys.CONTROL, "w").perform();28 driver.navigate().back();29 Thread.sleep(2000);30 actions.sendKeys(Keys.CONTROL, Keys.SHIFT, "t").perform();31 driver.navigate().forward();32 Thread.sleep(2000);33 Thread.sleep(2000);34 actions.sendKeys(Keys.CONTROL, "w").perform();35 driver.navigate().refresh();36 Thread.sleep(2000);37 actions.sendKeys(Keys.CONTROL, "w").perform();38 driver.navigate().refresh();39 Thread.sleep(2000);40 actions.sendKeys(Keys.CONTROL, "w").perform();41 driver.navigate().refresh();42 Thread.sleep(2000);43 actions.sendKeys(Keys.CONTROL, "w").perform();44 driver.navigate().refresh();45 Thread.sleep(2000);46 actions.sendKeys(Keys.CONTROL, "w").perform();47 driver.navigate().refresh();48 Thread.sleep(2000);49 } catch (Exception exception) {50 System.out.println(exception.getMessage());51 } finally {52 driver.quit();53 }54 }55}