Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem while adding description of an object using a varibale
#1
Not Solved
Dear friends,

I stored set of properties of a particular object in a string variable and use that variable with WebEdit object, But it was not working.

Code:
StrVar="name:=USER_NAME"+""""+","+""""+"visible:=True"
'MsgBox StrVar 'returns the exact value which needs to pass inside WebEdit
Browser("B1").Page("P1").WebEdit(StrVar).Set("Mercury")

For me this code return an error, that object not found in the application, But it is working if i directly use StrVar as below,

Code:
Browser("B1").Page("P1").WebEdit("name:=USER_NAME","visible:=True").Set("Mercury")

Can anyone help me to run the code successfully...
Waiting for reply...
Reply
#2
Not Solved
It will not work bro.....
Because the way u have initialized the variable, it means u have created a single string with two properties....

So as its a single string and dat separator comma (,) is also is a part of dat string, so QTP is not separating those two properties....its taking the full string as a single property irrespective of whether it contains comma or inverted, though its look like two different properties in run time....But for QTP its a single string property which contains those inverted commas and a comma....dats d reason y u getting object identification error....

In this case, remove the extra inverted commas dat u have added, Split dat string on basis of comma, then use dat array by position....

Like following....


Code:
StrVar="name:=USER_NAME"+","+"visible:=True"
StrVar = Split(StrVar,",")

now use----

Code:
Browser("B1").Page("P1").WebEdit(StrVar(0),StrVar(1)).Set("Mercury")


It will surely work......



Hope i am Clear to u......If not thn ping me in messanger....

-------------
Thanx.
Reply
#3
Not Solved
Dear Souvik,

Thanks for the reply...
wat i was actually trying is that, If we can directly pass it through one string variable then we could have avoid those making string array list, if condition checking etc and we can directly read form a excel sheet. if it is not possible we can leave it...

Thanks,
Shibin
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question adding two conditions into a while statement lotos 4 5,092 11-10-2017, 04:49 AM
Last Post: lotos
  Uft: Adding a property to all ojects into Repository ProTester 0 1,361 06-09-2017, 12:48 AM
Last Post: ProTester
  How to find out the object property in the Description language . njnirmal 9 6,682 05-19-2015, 12:30 AM
Last Post: qtptester66523
  HAVING PROBLEM IN CREATING OBJECT OF TEST BATCH RUNNER mayankchauhan 0 3,438 04-04-2014, 05:29 PM
Last Post: mayankchauhan
  adding an object to OR seven 1 2,659 02-17-2014, 02:23 PM
Last Post: basanth27

Forum Jump:


Users browsing this thread: 1 Guest(s)