How to recognize WebEdit objects inside the WebTable thru DP

84 views
Skip to first unread message

Mythili parasuraman

unread,
Mar 14, 2012, 10:35:37 PM3/14/12
to QTP eLearn Team


Hi All,
 

Need help in recognizing the web edit objects inside the web table thru DP to set the value from the test data.  Please look into the attachment for the screen shot. This is my first assignment and got held with the following... 

I searched in the Google group for answer but I didn’t get specific answer regarding this one! Please advice.

 

Function edit_input(fname,ftext)
    Dim mywe,mypg, objtable,mywele
   Set mypg = Browser("title:=.*").Page("title:=.*")
   Set objtable = description.Create()
   objtable("html tag").value="TABLE"
   objtable("index").value=0
 
   Set mywele= description.Create()
    mywele("innertext").value="First Name  M.I. Last Name  Email User ID  Your userid should be easy to remember. Password should be 8 to 20 letters and numbers. User Password  Confirm User Password  Pick a category below and then choose a picture that you will remember. If you forget your password, you will be asked to pick the same picture to recover your password.  Animals Birds Plants San Francisco Sky"
   mywele("html tag").value="DIV"
   mywele("class").value="BSFFirstSectionBox"
  
     
   Set mywe = description.Create()
   mywe("micclass").value ="WebEdit"
   mywe("name").value=fname
    mywe("html tag").value="INPUT"
 mywe("html id").value="AppFirstNameTB"
 mywe("type").value="text"
   mypg.WebTable(objtable).WebElement(mywele).WebEdit(mywe).Set ftext
   Set mypg = nothing
   Set mywt = nothing
   Set objtable= nothing
   Set mywele=nothing
End Function
 
Thanks
Mythili
Doc1.docx

Jitendra.S

unread,
Mar 15, 2012, 1:57:13 AM3/15/12
to qtp-ele...@googlegroups.com
check each section(field/TO) should run on dry run using Print log/MSG box and see whether its exist or not
then implement on main code..

I think prob is here

   mypg.WebTable(objtable).WebElement(mywele).WebEdit(mywe).Set ftext

madhu

unread,
Mar 15, 2012, 4:41:31 PM3/15/12
to Mythili parasuraman, QTP eLearn Team
Mythili - Could you please try this:

Function edit_input(fname,ftext)
   Dim mywe,mypg, objtable

   Set mypg = Browser("title:=.*").Page("title:=.*")

   Set objtable = description.Create()
   objtable("html tag").value="TABLE"
    
   Set mywe = description.Create()
   mywe("micclass").value ="WebEdit"
   mywe("name").value=fname
   mywe("html tag").value="INPUT"
   mywe("html id").value="AppFirstNameTB"
   mywe("type").value="text"

   mypg.WebTable(objtable).WebEdit(mywe).Set ftext

   Set mypg = nothing
   Set objtable = nothing
   Set mywe= nothing
   
End Function

Thanks & Regards,
Madhu

Mythili parasuraman

unread,
Mar 15, 2012, 5:41:30 PM3/15/12
to madhu, QTP eLearn Team

Thanks Madhu for your time. But still no luck in identifying the webedit object.

Along with your script i included the index property as 14 in the objtable and then tried , still having the same error msg!

Cannot identify the object "[ WebEdit ]" (of class WebEdit). Verify that this object's properties match an object currently displayed in your application.

 

 

Objects are looking like this in the object rep:


First Name    M.I    Last   --> this whole thing is a web table with properties (html tag :=TABLE, Index:=14)

First Name M.I Last  ---> webelement with properties (innertext :=First Name  M.I. Last Name  Email User ID.*, html tag := DIV, Class := BSFFIRSTSectionBox)

First Name  ---> WebEdit (type:= text, name:=ctl00$ContentPlaceHolderPageContent.*, html tag := INPUT)

Last Name   ---> WebEdit (type:= text, name:=ctl00$ContentPlaceHolderPageContent.*, html tag := INPUT)

User id     ---> WebEdit (type:= text, name:=ctl00$ContentPlaceHolderPageContent.*, html tag := INPUT)

Password    ---> WebEdit (type:= password, name:=ctl00$ContentPlaceHolderPageContent.*, html tag := INPUT)

Confirm Password ---> WebEdit (type:= password, name:=ctl00$ContentPlaceHolderPageContent.*, html tag := INPUT)

 

also tried the following and still the same error....

 


Function edit_input(fname,ftext)
    Dim mywe,mypg

   Set mypg = Browser("title:=.*").Page("title:=.*")

   wait 3


           
   Set mywe = description.Create()
   mywe("micclass").value ="WebEdit"
   mywe("name").value=fname
   mywe("html tag").value="INPUT"

   mywe("kind").value="singleline"
   mywe("type").value="text"
   mywe("html id").value="*TB"

   mypg.WebEdit(mywe).Set ftext

   Set mypg = nothing
   Set mywe = nothing
    
End Function

Error msg : Cannot identify the object "[ WebEdit ]" (of class WebEdit). Verify that this object's properties match an object currently displayed in your application.
Thanks
Mythili

madhu

unread,
Mar 15, 2012, 5:49:28 PM3/15/12
to Mythili parasuraman, QTP eLearn Team
Will you be able to send the html code for the doc you sent earlier, so that I can try at my end?

Thanks & Regards,
Madhu
Message has been deleted

Jitendra.S

unread,
Mar 16, 2012, 1:46:45 AM3/16/12
to qtp-ele...@googlegroups.com, madhu
ok lets solve it today..just want to know

Delete temporary files 1st start>>run>>type %temp%   and shift+delete all file

1'st thing
where you write this Function edit_input in same test file or different function lib?

2nd thing
This is not a mistake but just try it...
In" Function edit_input"    why you defined class as WebEdit two times..Either you defined in micClass
or you can write just as object name mywe      ex:  mypg.mywe.Set ftext...

3rd thing
If you are 3 files for each function then the variable u used are they defined as environment variable ?
If not then use it before that 1st put value of variable direct in code and run dry run
if it will work then try with environment variable..


And If possible then as a Madhu said send us html code,,

~J~



 



madhu

unread,
Mar 16, 2012, 2:30:13 AM3/16/12
to Jitendra.S, qtp-ele...@googlegroups.com
Hi Jitendra - that's not the case. First Name, M.I & Last Name are in another table [see Doc1.docx that mythily attached]. 

Regards,
Madhu

Jitendra.S

unread,
Mar 16, 2012, 2:40:34 AM3/16/12
to qtp-ele...@googlegroups.com, Jitendra.S

Hi Madhu
Do you have HTML code or URL of it? I think writing a code from scratch is best option at our end to provide solution

and clarify the things what exactly happening .

iTeLearn Help Team

unread,
Mar 17, 2012, 3:09:14 PM3/17/12
to mythilipa...@gmail.com, qtp-ele...@googlegroups.com
Can we try to use concept of childobject method for this.

Thanks,
--
iTeLearn Help Team
tech...@iTeLearn.com
QTPeLearn.com | SeleniumeLearn.com
Join me on YouTube and LinkenIn

Rajesh

unread,
Mar 18, 2012, 4:14:33 AM3/18/12
to iTeLearn Help Team, mythilipa...@gmail.com, qtp-ele...@googlegroups.com
the below code should work. try and let me know.

there are 20 tables in the page.
Firstname, middle initial(M.I) and lastname are in one table. table name is asterisk
EmailId and UserId are in another table. table name is ctl00$ContentPlaceHolderPageContent$AppEMail$AppEMailTB
Password and confirm password are in another table. table name is asterisk.

the problem is with the second table name. it contains $ in its name and $ is a regular expression character. so when you are creating a webtable object then you have to tell QT to treat $ as a RE character.
Instead of the name I used abs_x and abs_y for the 2nd table.


Browser("title:=.*").Page("title:=.*").WebTable("name:=asterisk","index:=0").ChildItem(2,1,"WebEdit",0).Set "mythili"
Browser("title:=.*").Page("title:=.*").WebTable("name:=asterisk","index:=0").ChildItem(2,2,"WebEdit",0).Set "p"
Browser("title:=.*").Page("title:=.*").WebTable("name:=asterisk","index:=0").ChildItem(2,3,"WebEdit",0).Set "raman"

Browser("title:=.*").Page("title:=.*").WebTable("abs_x:=147","abs_y:=336").ChildItem(2,1,"WebEdit",0).Set "som...@some.com"
Browser("title:=.*").Page("title:=.*").WebTable("abs_x:=147","abs_y:=336").ChildItem(4,1,"WebEdit",0).Set "mythili123"

Browser("title:=.*").Page("title:=.*").WebTable("name:=asterisk","index:=1").ChildItem(2,1,"WebEdit",0).Set "qtptesting"
Browser("title:=.*").Page("title:=.*").WebTable("name:=asterisk","index:=1").ChildItem(2,2,"WebEdit",0).Set "qtptesting"

thanks,
Rajesh

madhu

unread,
Mar 18, 2012, 5:05:10 AM3/18/12
to Rajesh, iTeLearn Help Team, mythilipa...@gmail.com, qtp-ele...@googlegroups.com

Wow, at last we got the solution. Thanks a lot Rajesh. I was struggling to set the values. You explained it very well. Thanks again!!


Here is the code to get the table & cell info, thought it might be useful, so just sharing.


Set table_ds = Description.Create()

table_ds("html tag").Value = "TABLE"

Set child_tables = Browser("name:=.*").Page("title:=.*").ChildObjects(table_ds)

 table_count = child_tables.Count

 print  "We have " & table_count &" tables"

 For tCount = 0 to table_count - 1 

 For t_rowCount = 1 to child_tables(tCount).RowCount

  For t_colCount = 1 to child_tables(tCount).ColumnCount(t_rowCount)

print "~~~~~~~TABLE~~~~~~~~~~ " & tCount

print  "Current Cell: " & t_rowCount  & "," & t_colCount

print  "CellData: " & child_tables(tCount).GetCellData(t_rowCount , t_colCount)

  Next   

 Next 

 Next 

Set child_tables = Nothing

Set table_ds = Nothing

 

Thanks & Regards,

Madhu

Rajesh

unread,
Mar 18, 2012, 8:24:33 AM3/18/12
to madhu, iTeLearn Help Team, mythilipa...@gmail.com, qtp-ele...@googlegroups.com
a small correction to what i wrote:

so when you are creating a webtable object then you have to tell QT not to treat $ as a RE character but to treat it as a literal.

Jitendra.S

unread,
Mar 18, 2012, 11:32:22 AM3/18/12
to qtp-ele...@googlegroups.com, madhu, iTeLearn Help Team, mythilipa...@gmail.com
Thanks Rajesh And Madhu ..
I want to know more about accessing webtable element using DP ,want to try it .
Could both of you suggest source/sites o get the same.?

fizza

unread,
Jun 21, 2012, 6:44:03 PM6/21/12
to qtp-ele...@googlegroups.com
Wow!!! Thanks all..here is the script and I've parameterized it as well

'**************************************************************
Set table_ds = Description.Create()
table_ds("html tag").Value = "TABLE"
table_ds("abs_x").value = 421
table_ds("abs_y").value  =  324

Set child_tables = Browser("name:=.*").Page("title:=.*").ChildObjects(table_ds)
 table_count = child_tables.Count
 print  "We have " & table_count &" tables"

Set oCheck = Description.Create()
oCheck("type").value = "checkbox"
oCheck("html tag").value = "INPUT"
oCheck("value").Value = "t"

Set objList=Browser("name:=.*").Page("title:=.*").ChildObjects(oCheck)

 For tCount = 0 to table_count - 1 
 For t_rowCount = 1 to child_tables(tCount).RowCount
  For t_colCount = 1 to child_tables(tCount).ColumnCount(t_rowCount)
print "~~~~~~~TABLE~~~~~~~~~~ " & tCount
print  "Current Cell: " & t_rowCount  & "," & t_colCount
print  "CellData: " & child_tables(tCount).GetCellData(t_rowCount , t_colCount)


'For objIndex=0 to objList.Count-1
If Trim (child_tables(tCount).GetCellData(t_rowCount , t_colCount)) = Trim(strName) Then
   objList(t_rowCount ).Click
blnFound = 1 ' done to exit the for loop once it find the expected checkbox
Exit For
End If
'Next

  Next

If blnFound = 1 Then
Exit For
End If
 Next 
  If blnFound = 1 Then
Exit For
End If
 Next 
Set child_tables = Nothing
Set table_ds = Nothing


'***************************************************************
Fizza
Reply all
Reply to author
Forward
0 new messages