-2

enter image description hereI want to read the code written inside an action in QTP,just as we read text file using FileSystem Object. Is there any way to read code written in action line by line ?

Ankit Tewari
  • 70
  • 1
  • 11
  • 1
    I don't use QTP but if it's VBScript can you show us an example of what you are trying to do? How is an action coded etc? So far you give us nothing to go off. I could reach inside your head and try and pick out the relevant bits but I'm not a brain surgeon either. – user692942 Mar 17 '16 at 11:32
  • I just want to read action whatever is coded inside it does not matter, that's why I didn't provided any code.You don't need to be a surgeon.Suppose there are 4 lines of code written in an Action of a test case made in QTP. My requirement is to read the action line by line as we read a normal text file using VB Script.Is there any way to do so.Thanks in advance. – Ankit Tewari Mar 17 '16 at 12:34
  • Ok let me be blunt, I don't know what an "Action" is in terms of QTP or how that fits into a VBScript. I do however know VBScript, so if you want my help give me something to work with. Do you have an example of an "Action" that involves interaction with VBScript can you provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve)? – user692942 Mar 17 '16 at 13:01
  • I have added Image showing a sample code in QTP Action. I just want to read the code written inside this Action of the Test Case. Anyone have any idea how to achieve it ? – Ankit Tewari Mar 18 '16 at 04:47

2 Answers2

1

So basically an action is attached to a QTP-Testcase. When you save this test case at a certain location, the code you have written is saved inside the directory named action1 or whatever action you were editing. In this folder you will find a file named script.AVCHD file. Open this in notepad and you will find your code inside it. Now all you got to do is write a simple visual basic, (or just any script you like) that will open this file and readall of the content into a variable. see if this helps. thanks.

jhoepken
  • 1,842
  • 3
  • 17
  • 24
Warhead007
  • 11
  • 2
1

For each test there will script.mts inside the Action1 folder. get the script text line

filename = "C:\YourUFTTest\Action1\script.mts"

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filename)

Do Until f.AtEndOfStream
  msgbox f.ReadLine
Loop

f.Close
Kiran Maroju
  • 174
  • 1
  • 2
  • 15