Micro Focus QTP (UFT) Forums
How to read value from WebPage? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to read value from WebPage? (/Thread-How-to-read-value-from-WebPage)



How to read value from WebPage? - sunnyvale69 - 12-15-2009

Hi - I am new to QTP and VB Script as well. I have recorded few user actions to create an order. At the end of my script it is creating an order. eg: An order# 123456 has been created successfully.

1) I would like to write this value (123456) to a text file (order.txt).
2. Launch Another URL to verify Order. Read the above order# from order.txt and type into a textbox..

Could someone guide me how can I acheive this?
I found this login elsewhere to write somethign to a file. I tested that it is writing "helloworld" in my test file. But I am not sure how to write a new order# into the file.
Code:
Dim fso, new_file
Set fso = createobject("scripting.filesystemobject")
Set new_file = fso.createtextfile("c:\testfile.txt", True)
new_file.writeline("hello world!")
new_file.close



RE: How to read value from WebPage? - Saket - 12-15-2009

store your order# in a variable say nOrder = 123456
and in place of 'helloworld' in your script use nOrder, like
Code:
nOrder = 123456
...
...
new_file.writeline nOrder
this will write your order number in the text file.
alternately if you store the order number in a variable, you can directly set this variable into a text box rather keeping it in a text file, unless you have other objectives to do so.


RE: How to read value from WebPage? - sunnyvale69 - 12-15-2009

Thank You Saket. I understand that. But How can I store a dynamic value in a variable? The order number changes every time. This is where I am blocked. On my webpage it shows : You Order # XXXXXX has been created. Eachtime, I run my script it has to capture different order number and store in the file for later use.


RE: How to read value from WebPage? - sunnyvale69 - 12-16-2009

Finally this is the workaround..Just closing the loop who may need it...

// Create Checkpoint per this website video http://motevich.blogspot.com/2008/03/qtp-how-to-capture-dynamic-text.html

Code:
Browser("Acme, Inc. |").Page("Acme Order Page").Frame("fbody_5").Output CheckPoint("fbody_5")

Dim fso, new_file, a
ordernum = DataTable.Value("order")
msgbox (ordernum)
Set fso = createobject("scripting.filesystemobject")
Set new_file = fso.createtextfile("c:\order.txt", True)
new_file.writeline(ordernum)
new_file.close