QTP - How to pass a value into an Object's Property's Value, using functions?

StackOverflow https://stackoverflow.com/questions/22087371

  •  18-10-2022
  •  | 
  •  

سؤال

Suppose i need to create a function as below :

Function CheckLink(name1,href1)
    if Browser(..).Page(..).Link("name:=name1","href:=href1").Exist Then
    Print "URL Exists"
End Function

I have a 7-8 links to test in which only these values change.

But the above Function is throwing error as the values name1 and href1 are being treated as name1 and href1 only, their values are not being passed through the function.

Please suggest what will be the correct way to write the above code.

Thanks.

هل كانت مفيدة؟

المحلول

How about

Function CheckLink(name1,href1)
    if Browser(..).Page(..).Link("name:=" & name1,"href:=" & href1).Exist Then
    Print "URL Exists"
End Function

Or, you could create a Description object instance, and put the property values in there. This would eliminate the string concatenations:

Dim D: set D=Description.Create
D.Add "name", name1
D.Add "href", href1
Dim O: Set O=Browser(..).Page(..).Link(D)

Hths.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top