HP-UFT : How affect an Object to a parameter? - hp-uft

I want affect an object to an UFT parameter, for execute a test with it in Input, something like that :
Set objData = objOnglet.UsedRange
Parameter("test") = objData
RunAction "fact_AC_InitEcxel", oneIteration, Parameter("test")
Someone has an idea ?

It cannot be done. You cannot pass objects through the Parameter.Value property.

Related

Using one variable for multiple items data in descriptive programming

I know that with Descriptive programming you can do something like this:
Browser("StackOverflow").Page("StackOverflow").Link("text:=Go To Next Page ", "html tag:=A").Click
But is it possible to create some kind of string so I can assign more than one data value and pass it as single variable? I've tried many combinations using escape characters and I always get error.
For example in the case above, let's say I have more properties in the Page object, so I'd normally have to do something like this:
Browser("StackOverflow").Page("name:=StackOverflow", "html id:=PageID")...etc...
But I'd like to pass "name:=StackOverflow", "html id:=PageID" as a single variable, so when writing many objects I'd only have to write:
Browser(BrowserString).Page(PageString).WebEdit("name:=asdfgh")
And the first part would remain static, so if the parents' data needs to be modified I'd only have to modify two variables and not all the objects created in all libraries.
Is it possible?
If I was not clear enough please let me know.
Thank you in advance!
I think what you're looking for is UFT's Description object
This allows you finer grained control on the description since in descriptive programming all values are regular expressions but with Description you can turn the regular expression functionality off for a specific property.
Set desc = Description.Create()
desc("html tag").Value = "A"
desc("innertext").Value = "More information..."
desc("innertext").RegularExpression = False
Browser("Example Domain").Navigate "www.example.com"
Browser("Example Domain").Page("Example Domain").WebElement(desc).Click
If you want to represent this with plain string then it's a bit more of a problem, you can write a helper function but I'm not sure I would recommend it.
Function Desc(descString)
Set ret = Description.Create()
values = Split(descString, "::")
For Each value In values
keyVal = Split(value, ":=")
ret(keyVal(0)).Value = keyVal(1)
Next
Set Desc = ret
End Function
' Usage
Browser("StackOverflow").Page("StackOverflow").WebElement(Desc("html tag:=H2::innertext:=some text")).Click
Further reading about descriptive programming.
As an alternative to Motti's excellent answer, you could also Set a variable to match your initial descriptive object and then extend it as required:
Set myPage = Browser("StackOverflow").Page("name:=StackOverflow", "html id:=PageID")
after which you can then use
myPage.WebEdit("name:=asdfgh")
throughout the rest of the code, so long as the myPage object stays in scope...

__V for property variable in jmeter

I have JMX structure such as,
ThreadGroup-1
Set propertyVariable-Content_0,Content_1,Content_3 etc
ThreadGroup-2
LoopController
Counter-counterNum
HTTPRequest--use PropertyValue as ${__V(__P(Content)_${CounterNum})}
above variable is not fetching value.
Got stuck on how to use __V for this case as it has property variable.
can someone explain me how to use __V when we have property variable.
You don't need __V() function here, you can access property value using __P() function directly like:
${__P(Content_${CounterNum},)}
Demo:
In case of malfunction double check that you're really setting the properties values using Debug Sampler and View Results Tree listener combination
you need to use this
${__V(MainVriableName_${CounterNo})}
1) Add Loop Controller
2) Under Loop Counter -> Add Counter (Starting value= 1, Increment = 1, Maximun value = ${MainVriableName_matchNr} and Exported Variable Name = CounterNo
3) After in the below Request(s) use ${__V(MainVriableName_${CounterNo})}
this works fine.

Optional parameters in ABAP CDS views?

I'm trying to create a CDS view for consumption with optional parameters. But at the moment, optional parameters are not supported.
Is there a workaround available to somehow choose which where clauses are to be executed/used based on input parameters ?
Did you check the Consumption.defaultValue annotation
Please have a look at reference document
I just put more complete answer than proposed by Dzhengo.
You can use parameter annotations for some of the parameters which can be filled implicitly by ABAP environmental values. Annotations can be specified by keyword #Environment.systemField before or after the parameter and should be followeed by env field after the colon. Here is the list of possible environmental fields:
#CLIENT:
sy-mandt
#SYSTEM_DATE:
sy-datum
#SYSTEM_TIME:
sy-uzeit
#SYSTEM_LANGUAGE:
sy-langu
#USER:
sy-uname
Sample code for defining the view:
#AbapCatalog.sqlViewName: 'ZVW_MARA'
#AccessControl.authorizationCheck: #NOT_REQUIRED
define view zvw_mara
with parameters
p_matnr : matnr,
#Environment.systemField : #SYSTEM_DATE
p_datum : syst_datum,
p_uname : syst_uname #<Environment.systemField : #USER
as select from
mara
{
key mara.matnr,
mara.ernam,
mara.ersda
}
where
matnr = :p_matnr
and ernam = :p_uname
and ersda = :p_datum;
At the moment the following are the only parameters you can use as optional.
p_date : sydatum
#<Environment.systemField:#SYSTEM_DATE
, p_language : spras
#<Environment.systemField:#SYSTEM_LANGUAGE

Create new method

I'm working with HP UFT. This tool use VBScript to automatics test.
Is it possible to create new method in function library.
I mean something like this.
Browser("Browser").Page("Page").WebEdit("login").MyMethod()
How can I do that?
Go to the Design menu, and select Function Definition Generator...
You'll get the following UI
Basically this is a helper for RegisterUserFunc.
By selecting the Register to a test object check-box (and which type of test object) the function you add will be available as a regular test object function.
Note that you can override an existing function, for example you can change Set to see if the value is "~today~" add today's date.
Adding User Defined Functions is actually pretty easy: define the function, decide on the object type you wish to add the function to, and use RegisterUserFunc to put it all together:
Function BrokenImage(ImageObject)
BrokenImage = True
ImageObject.WaitProperty "visible", True, 1000
ImageLoaded = False
StartTime = Now()
Do
If ImageObject.Object.naturalHeight > 0 And ImageObject.Object.naturalHeight > 0 Then
BrokenImage = False
Exit Do
End If
If DateDiff("s", StartTime, Now()) > 10 Then Exit Do
Loop While ImageLoaded = False
End Function
RegisterUserFunc "Image", "BrokenImage", "BrokenImage"
Once you've got the function defined, you call it as you would any other object method:
If Browser().Page().Image().ImageBroken() = true Then Print "Broken Image"
You can also add additional parameters which will then be passed to the new method.

Object variable not set error in vb6

Private m_IncidentDateRange As New MCWebServiceCOMWrapper.DateRange
Public Property Get IncidentDateRange() As MCWebServiceCOMWrapper.DateRange
IncidentDateRange = m_IncidentDateRange
End Property
Public Property Let IncidentDateRange(ByRef vNewValue As MCWebServiceCOMWrapper.DateRange)
Set m_IncidentDateRange = vNewValue
End Property
Error comes up in Get method please help
I would check the documentation for the MCWebServiceCOMWrapper.DateRange object and see if you are required to initialized it with values before you can use it. (maybe set a beginning and end date).
Don't you need to use "Set" there?

Resources