Row count after search, for a table from a form

Ask general questions here.
dc_alina
Posts: 8
Joined: Wed Sep 19, 2012 7:39 am

Row count after search, for a table from a form

Post by dc_alina » Wed Sep 19, 2012 8:00 am

KeyPass_eg.rar
Hi

I'm looking into Ranorex for a POC. As a startup, I'm using the KeePass application to record and add some usercode - trying to search for a word and then to count the results.
To search for results I'm using the following code:
Dim row1 As Row = Nothing
            Dim found As Boolean = Host.Local.TryFindSingle("/form[@controlname='MainForm']/container/container[@caption='' and @controltypename='SplitterPanel' and @instance='0']/container/container[@caption='' and @controltypename='SplitterPanel' and @instance='1']/table/row[@index='0'] ", row1)
            If found is True then
            'display how many results
                Dim list_row As IList(Of Row) = row1.Find(Of Row)("./table/row")
                'MsgBox("found "+bool.ToString)
                MsgBox("The Row count Found was : " + list_row.count.ToString)
            Next
Ranorex version: 3.3.2
OS: windows7 64 bit, SP1
But I get 0 result. Is there anthing that I'm missing?
Thanks
You do not have the required permissions to view the files attached to this post.

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Row count after search, for a table from a form

Post by artur_gadomski » Thu Sep 20, 2012 7:51 am

Try this:
Dim table As Table = Nothing  
Dim found As Boolean = Host.Local.TryFindSingle("/form[@controlname='MainForm']/container/container[@caption='' and @controltypename='SplitterPanel' and @instance='0']/container/container[@caption='' and @controltypename='SplitterPanel' and @instance='1']/table", table)  
If found is True then  
    'display how many results  
     'in C# it's FindChildern<Row>() Not sure how it looks in VB
     Dim list_row As IList(Of Row) = table.FindChildren(Of Row)() 
     'MsgBox("found "+bool.ToString)  
     MsgBox("The Row count Found was : " + list_row.count.ToString)  
Next
Basically use table as your starting point and then find it's children of type Row.

dc_alina
Posts: 8
Joined: Wed Sep 19, 2012 7:39 am

Re: Row count after search, for a table from a form

Post by dc_alina » Thu Sep 20, 2012 12:22 pm

Thank you, Artur. That did the job :)