Skip to content

Instantly share code, notes, and snippets.

@muditlambda
Created September 28, 2020 13:52
Show Gist options
  • Save muditlambda/7c9a648f2396f6fcff2f21a0fe2bb54a to your computer and use it in GitHub Desktop.
Save muditlambda/7c9a648f2396f6fcff2f21a0fe2bb54a to your computer and use it in GitHub Desktop.
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class keysDemo {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\Driver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com/");
driver.manage().window().maximize();
WebElement element = driver.findElement(By.xpath("//*[@id=\"tsf\"]/div[2]/div[1]/div[1]/div/div[2]/input"));
Actions action = new Actions(driver);
//holds the SHIFT key and converts the text to uppercase
action.keyDown(element,Keys.SHIFT).sendKeys("lambdatest").build().perform();
driver.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment