Micro Focus QTP (UFT) Forums
Cint function in UFT - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Cint function in UFT (/Thread-Cint-function-in-UFT)



Cint function in UFT - rinatk - 11-08-2015

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.


RE: Cint function in UFT - mikaelt - 11-08-2015

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


RE: Cint function in UFT - rinatk - 11-08-2015

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.


RE: Cint function in UFT - mikaelt - 11-08-2015

Hi Rinat,

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

Mikael


RE: Cint function in UFT - rinatk - 11-08-2015

'Hi mikaelt,

i did what you asked, i attached a screenshot.

thanks,
Rinat.


RE: Cint function in UFT - mikaelt - 11-08-2015

What you should do


RE: Cint function in UFT - mikaelt - 11-08-2015

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


RE: Cint function in UFT - rinatk - 11-09-2015

Hi Mikaelt,

i did what you've asked.


RE: Cint function in UFT - mikaelt - 11-09-2015

Hi Rinat,

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

Thanks

Mikael


RE: Cint function in UFT - rinatk - 11-09-2015

Hi Mikael,

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

Rinat Smile