Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can I use return value of Action1 in other Action2
#1
Not Solved
Hi All,
I want to use the return value of one action in to other action, please help me.

Scenario:
Action 1:- I am going to upload the details of a property/(real estate) in a, here the property id entered by the user is unique key,

Action 2:- In the Admin section of the site I want to Enable that property in the site for sale,

So I want to use the "Action 1" as re-usable action and want to return the "PropertyId" entered by User in "Action 1", So that I can use that perticular "property id" to search in the admin.

Many Thanks in advance.
Waiting for replies (URGENT!!!)

Please find the code snippet in the reply of this thread...
Reply
#2
Not Solved
Hi Ankur,
I have to do this...
' Action1 (Upload Property)
Code:
SystemUtil.Run "iexplore", "http://MyTestingSite.net"
Browser("MyTestingSite").Page("MyTestingSite").Image("MyTestingSite").Click
Browser("MyTestingSite").Page("MyTestingSite_2").Link("ESTATE AGENTS HOME").Click
Browser("MyTestingSite").Page("MyTestingSite_3").WebEdit("UcAgentLogin1$txtAgentName").Set "UserName"
Browser("MyTestingSite").Page("MyTestingSite_3").WebEdit("UcAgentLogin1$txtPassword").Set "Password"
Browser("MyTestingSite").Page("MyTestingSite_3").Image("Login").Click 34,11
Browser("MyTestingSite").Page("MyTestingSite_4").Link("add a new property").Click

Randomize()
propertyID="Property_"&int(100*rnd())

Browser("MyTestingSite").Page("MyTestingSite_5").WebEdit("UcNewPropertyToBuy1$txtPropert").Set propertyID
Browser("MyTestingSite").Page("MyTestingSite_5").WebEdit("UcNewPropertyToBuy1$txtAddress").Set "test"
Browser("MyTestingSite").Page("MyTestingSite_5").WebEdit("UcNewPropertyToBuy1$txtAddress_2").Set "test"
Browser("MyTestingSite").Page("MyTestingSite_5").WebEdit("UcNewPropertyToBuy1$txtTownToB").Set "test"
Browser("MyTestingSite").Page("MyTestingSite_5").WebEdit("UcNewPropertyToBuy1$txtCountyT").Set "test"
Browser("MyTestingSite").Page("MyTestingSite_5").WebList("UcNewPropertyToBuy1$drpRegionT").Select "London"
Browser("MyTestingSite").Page("MyTestingSite_5").WebEdit("UcNewPropertyToBuy1$txtPostCod").Set "BR 123"
Browser("MyTestingSite").Page("MyTestingSite_5").WebEdit("UcNewPropertyToBuy1$txtPropert_2").Set "Property Summary"
Browser("MyTestingSite").Page("MyTestingSite_5").WebEdit("UcNewPropertyToBuy1$txtDisplay").Set "Display Address"
Browser("MyTestingSite").Page("MyTestingSite_5").WebFile("UcNewPropertyToBuy1$Upload6").Set "file://path/image.jpg"
Browser("MyTestingSite").Page("MyTestingSite_5").WebEdit("UcNewPropertyToBuy1$MainImageT").Set "Image title"
Browser("MyTestingSite").Page("MyTestingSite_5").WebCheckBox("UcNewPropertyToBuy1$ckbSubmit").Set "ON"
Browser("MyTestingSite").Page("MyTestingSite_5").Image("UcNewPropertyToBuy1$btnSaveToB").Click 68,12
Browser("MyTestingSite").Page("MyTestingSite_6").Check CheckPoint("MyTestingSite")
Browser("MyTestingSite").Page("MyTestingSite_6").Link("Return home").Click
'---------------------------------------------------------------
Here I want to use the Property id as the return value for this Action1 so that I can use it in the Action2 to find out the property, and do some task with that property.
---------------------------------------------------------------

'Action2 (Publish Property)
Code:
RunAction "Copy of UploadProperty", oneIteration

SystemUtil.Run "iexplore","http://MyTestingSite.net/admin"
Browser("MyTestingSite").Page("MyTestingSite").WebEdit("txtusername").Set "UserName"
Browser("MyTestingSite").Page("MyTestingSite").WebEdit("txtpassword").Set "Password"
Browser("MyTestingSite").Page("MyTestingSiteS").WebButton("Login").Click
Browser("MyTestingSite").Page("MyTestingSite_2").Image("properties").Click
wait (2)

Dim row,i,strProperty,lnkImg

'+++++"I want here the return value of action1 i.e. the ProprtyToBePublish"++++++
ProprtyToBePublish = ??????????????? 'return value from action1
'++++"I want here the return value of action1 i.e. the ProprtyToBePublish"++++

msgbox ProprtyToBePublish
row = Browser("MyTestingSite").Page("MyTestingSite_2").Frame("Frame").WebTable("1").GetRowWithCellText(ProprtyToBePublish)
msgbox row
set lnkImg=Browser("MyTestingSite").Page("MyTestingSite_2").Frame("Frame").WebTable("1").ChildItem(row,5,"WebElement",0)
lnkImg.Click
Browser("MyTestingSite").Page("MyTestingSite").Frame("Frame_2").WebCheckBox("chkIsPublished").Set "ON"
Browser("MyTestingSite").Page("MyTestingSite").Frame("Frame_2").Link("Save Property").Click
--------------------
Also need to know If I can optimize some qtp script here.
Reply
#3
Not Solved
Hi, try using it as function and get the return value from it and then use it.
Else use a global variable and assign value to it in Action 1 and then access the value from Action 2
Reply
#4
Not Solved
Hi nageshpv,

How can use the script from "action1" as a Function,
Can u please explain with an example, I have written the code above for "action1".
Reply
#5
Not Solved
Yugal, try with the Global variable, that will be very simple.
Reply
#6
Not Solved
Hi All,

Inorder to use return value of Action1 in other actions like Action2,Action3....Action n in current script.

We can use the following features in QTP:
1) User defined Environment Variables (Create User defined Env. Var for return Value.....which inturn can be accessed by all other actions in Current script.)
2) Action Parameters (Output Parameters)
3) Output Values ( Output the required return value(Property Id) into RunTime Global Data Sheet present in Test Results window....which inturn can be accessed by all other actions in the current script)

Just try the above from your end & check it out.....I hope you can easily accomplish the required task.......
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Childobject return wrong checkbox count.. VpnQTP 1 2,886 04-09-2015, 09:07 PM
Last Post: babu123
  SQL on oracle database doesn't return a value Bluefields 2 3,330 07-09-2012, 01:23 PM
Last Post: Bluefields
  Return reusable object HelenN 0 4,409 04-20-2011, 08:31 PM
Last Post: HelenN
  VBScript - How to get the Function return value iamsekhar 2 22,794 09-13-2010, 04:16 PM
Last Post: lotos
  How to return multiple values from QTP User defined function dineshb 11 31,617 12-04-2009, 06:22 PM
Last Post: nil

Forum Jump:


Users browsing this thread: 1 Guest(s)