Forum Discussion

mesg2anil's avatar
mesg2anil
Regular Contributor
13 years ago

Handling Dynamic Objects

Hi,



Need information on how to handle dynamic objects?

For ex: If I give date range 01-Jan-2012 To 31-Mar-2012, this will create 3 rows as below...

Start Date            End Date

01-Jan-2012        31-Jan-2012

01-Feb-2012       29-Feb-2012

01-Mar-2012      31-Mar-2012



Similarly, If I give date range 01-Jan-2012 to 31-Dec-2012, it will create 12 rows... in this case, my application will create dynamic objects using name as "Item(001)", "Item(002)", "Item(003)"... till "Item(012)"

If I want to compare the value stored in above dynamic objects with excel sheet cell value... how should I compare them??
  • prakashk's avatar
    prakashk
    Occasional Contributor
    Hi Anil,



    Sub: How to handle Dynamic Objects in App



    Example: Item001, Item002....



    Take Object Type / Object Identifier, ColumnIndex / Row Index in Array

    ' Object Type / Objecct Identifier should be Unique

    'RowIndex / ColumnIndex should be vary



    Ex:

    Dim PropArray

    Dim ValuesArray

    Dim AppArray()

    Flag = 1

    RowSize = 1

    arraySize = 0

    Set iexplore = Aliases.IEXPLORE


     


    Set Page = iexplore.PageRegistration


    Page.Wait






    Do Until Flag = 0



    Redim Preserve AppArray(arraySize)

    PropArray = Array("ObjectType", "RowIndex")

    ValuesArray = Array("TextNode", RowSize)

    apData = Page.FindAllChildren(PropArray, ValuesArray, 12)

    If Ubound(apData ) < 0 Then

    Flag = 0

    Exit Do

    End If

    AppArray(arraySize) =  apData(0).innerText



    RowSize  = RowSize +1

    arraySize  = arraySize + 1

    Loop



    For I = 0 to ubound(AppArray) - 1

    log.message AppArray(I)

    Next



    'This script for getting data from app

    If u want more details send me a detailed problem and screen shot, I'll Explain You...

    Feel free to contact me, if u have any doubts



    Regards,

    -Prakash

    prakashraju06@gmail.com
  • mesg2anil's avatar
    mesg2anil
    Regular Contributor
    Hi Prakash,



    Thank you for replying



    Actually, what exactly i'm looking is, in an application when I enter some data, that data will result multiple objects on the page which will have value... for example If I say enter your full name in the object: "Anil Yadrami"

    below it will create two objects saying

    first name: Anil

    last name: Yadrami

    so the objects which hold the value Anil and Yadrami are dynamic objects, those objects names will change based on the application and the number of rows it is generating everytime... so in this situation if I to consider the object value "Yadrami", how will I know which object is holding this value? :)
  • prakashk's avatar
    prakashk
    Occasional Contributor
    Hi Anil,



    I understand some what in your question.



    1. Here ObjectType is Unique, so no need to worry about this.

    2. Don't take the ObjectIdentifier property. bcz it'll always dynamic (Anil or prakash like that right?)

    3. In Your Case RowIndex is different - so no need to worry about this.



    I Hope above script is working, but if you know any of the page like google or etc. send the details, i'll do and let you know the solution





    Regards,

    -Prakash

    prakashraju06@gmail.com
  • mesg2anil's avatar
    mesg2anil
    Regular Contributor
    Hi Prakash,



    Thank you for replying...



    I'm attaching screenshots for more details...

    In screenshot "ObjectHanlding1.jpg" when I click on the link, it will open another window, it is shown in second screenthot "Object Handling2.jpg". In 2nd screenshot I marked the table which will have multiple rows based on the tenure which is underlined. The object names in the table will change everytime there is change in the tenure, for example: if I'm taking Installment Amount, first amount object name will be "Item(21)", if the tenure is 6months. In case if the tenure changes to 7 months, the object name might become "Item(30)". I want to compare the Installment amount with excel sheet, so in this kind of situation, how to make sure the values and object names what I'm comparing with excel are correct?
  • Hi,



    You can find information on working with web tables in the Parsing HTML Tables help topic. By parsing data in your table, you can get all values you need.
  • prakashk's avatar
    prakashk
    Occasional Contributor
    Hi Anil,



    Here, using the object spy you can find the row count

    Ex:



    Dim AppArray()



    PropArray = Array("ObjectType","ObjectIdentifier", "innerText")

    ValuesArray = Array("Table", "0", "*Installment*")

    ScheduleTable = Page.FindAllChildren(PropArray, ValuesArray, 11)

    ScheduleRowCount= ScheduleTable (0).RowCount



    J = 0

    ColumnStart = 0

    Flag = 1

    Size = 0

    If ScheduleRowCount>1 Then

    Do Until Flag = 0

    Redim Preserve AppArray(Size)



    'Get the Data from Cell

    PropArray = Array("ObjectType","ObjectIdentifier", "ColumnIndex")

    ValuesArray = Array("Cell", J, ColumnStart)

    TableData = ScheduleTable(0). FindAllChildren(PropArray, ValuesArray, 11)



    If  Ubound(TableData) < 0 Then

    Flag = 0

    Exit Do

    End If

    AppArray(Size) = TableData (0).innerText



    Size = Size+1

    J = J + 1

    ColumnStart = ColumnStart+1

    Loop

    End If



    'Print the Data



    For K = 0 to Ubound(AppArray) - 1

     log.message AppArray(K)

    Next



    I hope it is definitely work.



    Regards,

    -Prakash