Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy content from a text file & paste it in text area in a web page
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi,

Can anyone please tell me how to automate copying the content from a text file and pasting it on a text area of a web browser?

The code I have tried copies the content and pastes it on the QTP expert view as a huge line. It is a big text file and I don't want the content to be copied as inline text in QTP. Is this possible?

Please Help!
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi
Yes, it's possible.
Before running test you can save text, that should be copied, to some text file.
Below code that opens this file and reads it's content to some variable. As I understand, you know how to paste text in text area of browser, and you just need code how to read text from file.
I write function for you that receives pathToFile as argument and returns text, that this file contains:
Code:
Function readTextFromFile(pathToFile)
  'creating File System Object
  Set fso = createObject("Scripting.FileSystemObject")
  If fso.FileExists(pathToFile) = True Then
   'open text file for reading
   Set f = fso.openTextFile(pathToFile, 1)
   'read all text from file and return it to function
   readTextFromFile = f.ReadAll
   'close file
   f.Close
  End If
End Function

Using this function:
Code:
text = readTextFromFile(filePath)
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
Thank you so much. It worked. Thanks again.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Read Content inside PDF kotaramamohana 0 1,203 09-02-2020, 05:49 PM
Last Post: kotaramamohana
  Can QTP handle slick grid table in a web page qtplearner88 2 4,506 10-01-2019, 10:44 AM
Last Post: shilpi952
  Capture All text from webpage and copy it... mpatra 3 5,258 07-25-2018, 05:33 PM
Last Post: vimlesh
  how to write the content obtained using the method GetPdfText Anisha 0 1,434 10-24-2017, 08:49 PM
Last Post: Anisha
  LearnQuickTestPDF -does not work on just getting the text jloyzaga 0 1,338 02-10-2017, 10:59 AM
Last Post: jloyzaga

Forum Jump:


Users browsing this thread: 1 Guest(s)