Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to read value from WebPage?
#1
Solved: 11 Years, 4 Months ago
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
Reply
#2
Solved: 11 Years, 4 Months ago
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.

Reply
#3
Solved: 11 Years, 4 Months ago
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.
Reply
#4
Solved: 11 Years, 4 Months ago
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...-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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Want to read the data from excel and set read value in the JavaTable rajeevk7 0 2,309 07-10-2017, 04:20 PM
Last Post: rajeevk7
  webpage WinObject has same name Ananthakumar_S 0 1,693 11-30-2016, 09:48 PM
Last Post: Ananthakumar_S
  Check specific links of a webpage rocky9 1 2,705 06-11-2015, 06:23 PM
Last Post: venkatesh9032
Exclamation How to verify whether pdf is completely loaded or not in webpage nmakkena 1 2,674 08-27-2014, 04:09 PM
Last Post: vinod123
  Handling .NET framework menu in webpage using QTP 10 vishnu1067 0 2,333 05-15-2014, 05:30 PM
Last Post: vishnu1067

Forum Jump:


Users browsing this thread: 1 Guest(s)