Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Object not found when creating an object during runtime
#1
Not Solved
Hi guys! Can anyone help me with my code? I'm trying to create an object (java textfield) during runtime and input something to that field using the following code:

Code:
            Set txtSearchField = Description.Create()
                txtSearchField("Class Name").Value = "JavaEdit"
            Set objSearchField = objWindow.ChildObjects(txtSearchField)
            
            If valReqdObjClass = "JavaEdit" Then
                objWindow.JavaEdit(txtSearchField).Set valReqdObj
            End If

but the thing is, when I call this code:

Code:
MsgBox objSearchField(0).GetROProperty("attached text")

it always returns nothing. Also, I cannot access the object when I am already trying to input something to it (QTP always returns that object cannot be found). Is there something wrong in the way that I created the object?? Help anyone?
Reply
#2
Not Solved
Hello,

Add more properties to txtSearchField
I think you can use objSearchField as well
Can you pleas try

Code:
objWindow.objSearchField(txtSearchField).Set valReqdObj

Let us know how it goes.
Reply
#3
Not Solved
Hi Tarik!

Actually, the txtSearchField description for the JavaEdit text box is found in several forms (all of them are search forms), meaning, that this particular text box will differ in its attached text and its developer name for each form. So, I don't think I can add any more specific properties. Although I did find some sort of workaround though:

Code:
            Set txtSearchField = Description.Create()
                txtSearchField("Class Name").Value = "JavaEdit"
            Set objSearchField = objWindow.ChildObjects(txtSearchField)

            strAttachedText = objSearchField(0).GetROProperty("attached text")
            strDeveloperName = objSearchField(0).GetROProperty("developer name")

            ' Input the value into the search field
            If strDeveloperName <> "" Then
                objWindow.JavaEdit("developer name:=" & strDeveloperName).Set valReqdObj
            ElseIf strAttachedText <> "" Then
                objWindow.JavaEdit("attached text:=" & strAttachedText).Set valReqdObj
            End If

Also, when I tried doing your suggestion, I encountered an "Unspecified error" runtime error:

Code:
            Set txtSearchField = Description.Create()
                txtSearchField("Class Name").Value = "JavaEdit"
            Set objSearchField = objWindow.ChildObjects(txtSearchField)

            strAttachedText = objSearchField(0).GetROProperty("attached text")
            strDeveloperName = objSearchField(0).GetROProperty("developer name")

            ' Input the value into the search field
            If strDeveloperName <> "" Then
                objWindow.objSearchField(txtSearchField).Set valReqdObj
            ElseIf strAttachedText <> "" Then
                objWindow.JavaEdit("attached text:=" & strAttachedText).Set valReqdObj
            End If
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Object not found during the 2nd iteration of an Action call in a For loop BGunay 0 968 04-23-2020, 07:08 PM
Last Post: BGunay
  Collecting Objects And Object State At Runtime zunebuggy 3 1,718 11-22-2017, 02:37 PM
Last Post: supputuri
  object spy not recognizing object.. pleaseeeee help Sonia Sadeque 3 3,438 12-22-2016, 02:42 PM
Last Post: ishan.mahajan@adp.com
  When trying to recognize the object in QTP, each object is recognized as “WinObject:S geetasarvadnya 2 3,763 10-28-2015, 12:34 PM
Last Post: vinod123
  Object repository losing object properties ishan.mahajan@adp.com 2 3,760 08-20-2015, 11:33 PM
Last Post: ADITI1992

Forum Jump:


Users browsing this thread: 2 Guest(s)