Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cint function in UFT
#1
Solved: 9 Years, 1 Month, 2 Weeks ago Shy 
Hello,

i have a test in a web, the problem starts when the test needs to click on a random line from a table.
i have this code that was working in QTP10:
Public Function SelectObject(strItem)

    Dim objPage,objFrame,objTBL,iStartSearchFromRow,iKeyColumnIndex
    Dim index
    Dim strCurrentSearchName
    Dim iRowCount,bFound
    Dim bLastPage
    Dim objWebElement

    Set objPage = Browser("MainBrowser").Page("pageMain")
    Set objFrame = Browser("MainBrowser").Page("pageMain").Frame("frmNewMainScreen")
    Set objTBL = Browser("MainBrowser").Page("pageMain").Frame("frmNewMainScreen").WebElement("tblObjects")
    iStartSearchFromRow = 1
    iKeyColumnIndex = 4
    
    'Creating a description object
    Set objWebElement = Description.Create()
    'Add descriptions and properties
    objWebElement("Class Name").Value = "WebElement"
    objWebElement("innertext").Value = strItem
    objWebElement("Index").Value = 1
    
   Err.Clear

   bFound = False
   bLastPage = 1

   Do While bLastPage = 1 ' bLastPage = -1 when last page is displayed in the table
       iRowCount = Cint(objTBL.RowCount)
       For index = iStartSearchFromRow To iRowCount
            strCurrentSearchName = objTBL.GetCellData(index,iKeyColumnIndex)
            If  Ucase(Trim(strCurrentSearchName)) = Ucase(Trim(strItem)) Then'  If value found, check the line and exit for
                'Browser("MainBrowser").Page("pageMain").Frame("frmNewMainScreen").WebElement(objWebElement).Click
                Browser("MainBrowser").Page("pageMain").Frame("frmNewMainScreen").WebElement("tblObjects").Click
                Browser("MainBrowser").Page("pageMain").Sync
                wait(5)
                bFound = True
                Exit For
            End If
        Next
        If bFound Then
            Exit Do
        End If
        bLastPage = JumpToNextPage(objPage,objFrame)
   Loop

    Set objPage = Nothing
    Set objFrame = Nothing
    Set objTBL = Nothing
    Set objWebElement = Nothing

    If Err.Number <> 0 Then
        SelectObject = EXIT_UNEXPECTED
    End If

    If bFound Then
        SelectObject = EXIT_SUCCESS
    End If

End Function

now i am working with UFT12.
i get an error message:
object does not support this property or method:
  iRowCount = [b]Cint(objTBL.RowCount)[/b]

can anyone help me figure out what is the problem?

thanks,
Rinat.
Reply
#2
Solved: 9 Years, 1 Month, 2 Weeks ago
Hi Rinat,

I don't have access to your application under test so I have to ask you to let the error pop up appear and click on "Debug". What worth objTBL.exist in context. From my point of view the problem is not from QTP, but that your object doesn't exist in context, so, the Method "RowCount" doesn't work.

Please update Wink

Mikael
Reply
#3
Solved: 9 Years, 1 Month, 2 Weeks ago
Hi mikaelt,

i added the row "objTBL.Exist" before the "iRowCount..." and i get the same error "object doesnt support this method..."
when i watch objTBL i see that its value = <Object> from type object.
Reply
#4
Solved: 9 Years, 1 Month, 2 Weeks ago
Hi Rinat,

I didn't mean you to add anything. Just watch "objTBL.Exist" after the pop up error appear...

Mikael
Reply
#5
Solved: 9 Years, 1 Month, 2 Weeks ago
'Hi mikaelt,

i did what you asked, i attached a screenshot.

thanks,
Rinat.


Attached Files Image(s)
   
Reply
#6
Solved: 9 Years, 1 Month, 2 Weeks ago
What you should do
Reply
#7
Solved: 9 Years, 1 Month, 2 Weeks ago
From my point of view, you will get a false .

Explainations :

When you do // Set objTBL = Browser("MainBrowser").Page("pageMain").Frame("frmNewMainScreen").WebElement("tblObjects")

It calls for an object in Repository. And it seems that this object is not recognized.

I think you've forgot to put this object in Local repository when you moved to V12, or, if it is a shared repository, you ve forgot to link your relevant tsr file.

So made these checks, and update us. Wink
Reply
#8
Solved: 9 Years, 1 Month, 2 Weeks ago
Hi Mikaelt,

i did what you've asked.
Reply
#9
Solved: 9 Years, 1 Month, 2 Weeks ago
Hi Rinat,

In console, please type objtbl.highlight, and check the object highlighted is the one you meant.

Thanks

Mikael
Reply
#10
Solved: 9 Years, 1 Month, 2 Weeks ago
Hi Mikael,

i changed the object in the repository and the issue was resolved.
thanks for all your help!

Rinat Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling a function in a Test Script from a function library anupam4j 3 6,180 06-26-2015, 12:31 AM
Last Post: babu123

Forum Jump:


Users browsing this thread: 1 Guest(s)