ソリューションです。
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class CopyFileToTextbox {
public static void main(String[] args) {
File inFile = new File("D:\\path\\to\\notepad\\file\\TextFile1.txt");
StringBuilder targetString = new StringBuilder("");
try {
FileReader fr = new FileReader(inFile);
BufferedReader br = new BufferedReader(fr);
String s = null;
while ((s = br.readLine()) != null) {
targetString.append(s);
}
} catch (IOException e) {
e.printStackTrace();
}
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
WebDriverWait wait = new WebDriverWait(driver,10);
wait.until(ExpectedConditions.presenceOfElementLocated(By.name("q")));
driver.findElement(By.name("q")).sendKeys(targetString);
driver.findElement(By.name("btnG")).click();
driver.quit();
}
}