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