To Copying the word or sentence and Pasting into the input field, we can use character sequence in selenium scripts.
Below is an example to paste the search queries on Google Search Engine.
Note : Before that open your notepad. Key something which you would like to search, I had written on my notepad "World Wrestling Entertainment" and copied using CTRL + C.
Now try the below code for pasting into the search input box.
Code:
Below is an example to paste the search queries on Google Search Engine.
Note : Before that open your notepad. Key something which you would like to search, I had written on my notepad "World Wrestling Entertainment" and copied using CTRL + C.
Now try the below code for pasting into the search input box.
Code:
import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; public class CtrlC{ public static void main(String[] args) throws InterruptedException{ //Launching firefox Browser WebDriver driver = new FirefoxDriver(); //Launching google search driver.get("http://www.google.com"); Thread.sleep(5000); driver.findElement(By.name("q")).sendKeys(Keys.CONTROL + "v"); } }