Micro Focus QTP (UFT) Forums
How can I send variable value to html property for descriptive programming in QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: How can I send variable value to html property for descriptive programming in QTP (/Thread-How-can-I-send-variable-value-to-html-property-for-descriptive-programming-in-QTP)

Pages: 1 2


How can I send variable value to html property for descriptive programming in QTP - ritugoyal - 07-24-2009

Hi All,

Please can any body tell me How can I send variable value for HTML property for descriptive programming in QTP.

e.g.
Code:
Dim testid, i,j
i=1
j = Cstr(i)
testid = "Edit"+j

Browser(browsers).Page(pages).WebButton("html tag:=Input", "html ID:=testid").Click

Here i is variable. But when am sending testid as a value to html ID , its throwing me error , I guess there is some string error because of double qoutes. Can any body help me to resolve this problem.

Thanks,
Ritu


RE: How can I send variable value to html property for descriptive programming in QTP - QTPian - 07-24-2009

Hi Ritu,

You can send a value to a html property by using & symbol.
_____________
Code:
name = "Login"
Browser("name:=name").Page("page:=p").webbutton("name:="&name).click
______________

But I dunno how to use more than one property (like using html tag and html id, that u hav used in your LOC) in descriptive programming. If anybody know, Please let me know.

Thanks,


RE: How can I send variable value to html property for descriptive programming in QTP - supputuri - 07-24-2009

Hi Ritu,

Code:
Browser(browsers).Page(pages).WebButton("html tag:=Input", "html ID:=" & testid).Click

that's it.
Remember one thing use "&" for concatenation of two expressions once the string is closed.

@QTPian : we can use the same syntax for ever more than one property.

Let me know if you need any more info.


RE: How can I send variable value to html property for descriptive programming in QTP - QTPian - 07-24-2009

Hi QTPKing..

Thanks for your reply. But the same is not working for me.. I am getting the following error message,
"Cannot identify the object "[ WebButton ]" (of class WebButton). Verify that this object's properties match an object currently displayed in your application."

here is my code,
Code:
Systemutil.Run "iexplore.exe", "http://www.bing.com"
Dim testid
testid = "sb_form_go"
Browser("name:=Bing").Page("title:=Bing").WebButton("html tag:=INPUT,  html id:="&testid).Click

Please let me know of the issues in the same.

Thanks,


RE: How can I send variable value to html property for descriptive programming in QTP - supputuri - 07-24-2009

Hi QTPian,

Check out the below LOC and let me if you need any more info.

Code:
btnName = "Google Search"
Browser("Google").Page("Google").webbutton("html tag:=INPUT","name:=" & btnName).highlight



RE: How can I send variable value to html property for descriptive programming in QTP - QTPian - 07-24-2009

Thanks QTPKing.. When the "name" property is used, the script is working fine. But the combination of "html tag" and "html id" is not working. I dunno why it is not working.. Any comments on this?


RE: How can I send variable value to html property for descriptive programming in QTP - ritugoyal - 07-24-2009

Thanks buddies,
Thanks a lot for ur help. It(WebButton("html tag:=Input", "html ID:=" & testid)) worked for me.

Regards
Ritu


RE: How can I send variable value to html property for descriptive programming in QTP - QTPian - 07-24-2009

Hey Guys, I got the issue in my LOC. The working code is
------
Code:
Browser("name:=Bing").Page("title:=Bing").WebButton("html tag:=INPUT", "html id:="&testid).Click
----------
instead of which I was trying with
--------
Code:
Browser("name:=Bing").Page("title:=Bing").WebButton("html tag:=INPUT, html id:="&testid).Click
--------
and continuously got the error message.

Thanks,


RE: How can I send variable value to html property for descriptive programming in QTP - supputuri - 07-24-2009

Hi QTPian,

I think you are ok with the code now. The only thing is we should close one property and then define the other property then only it will work.

Let me know you need any info.


RE: How can I send variable value to html property for descriptive programming in QTP - QTPian - 07-24-2009

Thanks QTPKing.. Its working... Thanks once again for explaining in detail...