Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am facing an issue with moving large chunk of data from file to TextArea in the app.

Its taking lots of time and inputing data Line by line ...

Please find the code snippet below and suggest if something can be done to make it fast.

This is the code to read file content using streams.

public static String readFileDataAsString(String filePath) {

byte[] buffer = new byte[(int) new File(filePath).length()];
BufferedInputStream f = null;
try {
f = new BufferedInputStream(new FileInputStream(filePath));;
} catch (Exception e) {
finally {
//Closing the file.
if (f != null) try { f.close(); } catch (IOException e) {
return new String(buffer);


Code to send File content to UI Field in Selenium is:

String data;
data = readFileDataAsString(filePath)

also, tried selenium.type("locator", data)

share|improve this question

You can set the textarea's value more quickly using the executeScript method on the JavascriptExecutor interface. For example, suppose your textarea looks like this:

<textarea id='t'></textarea>

You can set its value like this:

driver.executeScript("var t = document.getElementById('t'); "+
                     "t.value = arguments[0];",

This worked for me using Firefox 10.0.2 and Selenium/WebDriver 2.20.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.