Forum Discussion

pashooo's avatar
pashooo
Contributor
13 years ago

confusion in treeviewitem name defininition

Helllo, everybody)





I faced a strange problem, m.b. bug... Im confused.


I have a list of 2 items:


IN00 - WPFObject("TreeViewItem", "", 1) - names from object spy...


IN00000 - WPFObject("TreeViewItem", "", 2)





My code:


for(i=1;i<11;i++)


{


    F_add_new_acc(i); //- function add new items named "i"... 


                                    //list is sorted by name


                                    // list after first iteration  1,IN00,IN00000


                                    // list 2 first iteration  1,2,IN00,IN00000

                                    // list 3 first iteration  1,2,3,IN00,IN00000


                                    // list 4 first iteration  1,2,3,4,IN00,IN00000


                                    // list 5 first iteration  1,2,3,4,5,IN00,IN00000.... etc


     if(i<9)


    {


          aqObject.CheckProperty(treeview_acc.WPFObject("TreeViewItem", "", (i+1)).DataContext, "Name", 0, "IN00");


          aqObject.CheckProperty(treeview_acc.WPFObject("TreeViewItem", "", (i+2)).DataContext, "Name", 0, "IN00000");


          aqObject.CheckProperty(treeview_acc.WPFObject("TreeViewItem", "", i).DataContext, "Name", 0, i);

     }


 } 




... so after the first iteration test says:





Object: 




Property: Name




Expected value: "IN00"




Actual value: IN00000



... about the line:


aqObject.CheckProperty(treeview_acc.WPFObject("TreeViewItem", "", (i+1)).DataContext, "Name", 0, "IN00");


the list at that moment is: 1,IN00,IN00000


IN00 is WPFObject("TreeViewItem", "", 2), says object spy, i=1... =>


aqObject.CheckProperty(treeview_acc.WPFObject("TreeViewItem", "",2).DataContext, "Name", 0, "IN00"); must by true, but false....





Have anybody have the same trouble?





4 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Pasha,



    There seems to be some inconsistency in your post (or a misunderstanding on my part).



    You first wrote:

    I have a list of 2 items:

    IN00 - WPFObject("TreeViewItem", "", 1) - names from object spy...

    IN00000 - WPFObject("TreeViewItem", "", 2)
    And then you wrote:
    IN00 is WPFObject("TreeViewItem", "", 2), says object spy


    So, which item does WPFObject("TreeViewItem", "", 2) actually correspond to - IN00000 or IN00?

    If it corresponds to IN00000, like you wrote in the beginning, then the checkpoint's result is correct.



    If I misunderstood you, please correct me and explain the problem a bit further so we can better understand what's happening.
  • At first time list is:




    IN00 - WPFObject("TreeViewItem", "", 1)


    IN00000 - WPFObject("TreeViewItem", "", 2)

    _____________________________________


    after adding an item (F_add_new_acc(i); //- function add new items named "i", i==1) named "1" list becomes:




    1 - WPFObject("TreeViewItem", "", 1)


    IN00 - WPFObject("TreeViewItem", "", 2)


    IN00000 - WPFObject("TreeViewItem", "", 3)

    _____________________________________


    after adding next item  (F_add_new_acc(i); //- function add new items named "i", i==2) named "2":




    1 - WPFObject("TreeViewItem", "", 1)


    2 - WPFObject("TreeViewItem", "", 2)


    IN00 - WPFObject("TreeViewItem", "", 3)


    IN00000 - WPFObject("TreeViewItem", "", 4)


    _____________________________________


    etc




    checkpoint crashs when i==1....

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Pasha,



    Try inserting the Refresh method call before doing the checkpoints:



    if(i<9)

    {

    treeview_acc.Refresh();

    aqObject.CheckProperty(treeview_acc.WPFObject("TreeViewItem", "", (i+1)).DataContext, "Name", 0, "IN00");

    ...


    Does this help?



    As far as I understand, if new tree items are added dynamically at the runtime, the "cached" object reference stored in the treeview_acc variable may not detect newly added child objects automatically. So, the forced Refresh should do the trick.