Question

When an action is performed, it will last for a while to get a message showing that this action is successful. Here I use a function to test if the message comes out:

    For i = 0 To NumberOfiframe - 1
       Set objPage = iframe(i).Object 
       Set objTag = objPage.GetElementsByTagName("span") 

       intTotalLink = objTag.Length - 1

       For intCtr = 0 to intTotalLink 

          If objTag(intCtr) = null Then
          Exit Function
          End If

          strContent = objTag(intCtr).InnerText 

          endPosition = InStr(1, strContent, "Not all transport requests yet")

          If endPosition > 0  then 
                TRNotReleased = FALSE
                Exit for
          End If


      Next 
  Next

while when the message comes out, QTP will pop up a window showing "Object Required: objTag(..)", my point is that QTP is not able to find the set object when Web UI changes.

As the message contains different information for each operation, is there any solutions for me to get over from this issue?

Thanks in advance.

Was it helpful?

Solution

When you use objPage.GetElementsByTagName you're getting a reference to a DOM object on the page, this is not a QTP test object but rather an object belonging to the browser. When the DOM in the browser changes the object you're holding onto ceases to be valid.

If you want to access the object after the HTML changes you'll have to ask QTP to retrieve it again. Perhaps like this:

For i = 0 To NumberOfiframe - 1
   Set objPage = iframe(i).Object 
   Set objTag = objPage.GetElementsByTagName("span") 

   intTotalLink = objTag.Length - 1

   For intCtr = 0 to intTotalLink 
      ' Get the collection of objects again
      Set objTagCurr = objPage.GetElementsByTagName("span")
      Set currObj = objTagCurr(intCtr)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top