Selenium Java to copy and paste the text in an input field
KW.java
import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; class KW { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "/home/kodingwindow/drivers/chromedriver"); WebDriver driver = new ChromeDriver(); driver.get("https://kodingwindow.com/testapp/"); driver.findElement(By.name("username")).sendKeys("kodingwindow"); driver.findElement(By.name("username")).sendKeys(Keys.CONTROL, "a"); driver.findElement(By.name("username")).sendKeys(Keys.CONTROL, "c"); driver.findElement(By.name("password")).sendKeys(Keys.CONTROL, "v");; driver.findElement(By.name("login")).click(); driver.close(); } }
Comments and Reactions
Advertisement