Search code examples
vbscriptqtphp-uft

How to select all text displayed in browser and copy and paste it in the Notepad?


I would like to select all of the text displayed on the page and paste it into the Notepad. I have the following code but it is not working.

Browser("Display Token").Page("Display Token").WebEdit("html tag:=TEXTAREA").Click
Browser("Display Token").Page("Display Token").WebEdit("html tag:=TEXTAREA").Type  micCtrlDwn + "a" + micCtrlUp
Browser("Display Token").Page("Display Token").WebEdit("html tag:=TEXTAREA").Type  micCtrlDwn + "c" + micCtrlUp

The first line with a Click did work, but for the 2nd line I'm getting the following error:

Object doesn't support this property or method: Browser (..).Page(...).WebEdit(...).Type'


Solution

  • Why do you want to copy and paste the text?

    To get the text of the webpage using QTP/UFT

    sPageText = Browser("Display Token").Page("Display Token").object.innerText 
    

    To write to a txt file,

    Set oFSO=CreateObject("Scripting.FileSystemObject")
    oFileName="c:\<filepath>\pagecontent.txt"
    Set oFile = oFSO.CreateTextFile(oFileName,True)
    oFile.Write sPageText 
    oFile.Close