Page 1 of 1

Verify order of elements

Posted: Thu Dec 01, 2011 3:12 am
by Rakesh123
Hi Frnds,
I have a small requirement.I am doing automation testing for an application developed in Delphi. I have some 'n' number of elements inside the parent node of the Tree.When I select the parent node & click on button all the child nodes should be added in the panel which is beside the tree.

Till here its fine..

I need to verify whether the items are displayed in correct order or not.

Its not alphabetical order.Actually they have given some order.For Eg:If there are 3 child nodes(A,B,C),they should be displayed in the panel as C,A,B but not as A,B,C

So,pls help me out in solving this ASAP.

Please don't send any urls..

Thanks,
Rakesh

Re: Verify order of elements

Posted: Thu Dec 01, 2011 9:50 am
by Support Team
Hi,

Please provide more details about the context you are trying to verify the order (within spy? within the code?...).
Also tell me what exactly you are trying to do.
Thanks.

Best Regards,
Martin
Ranorex Support Team

Re: Verify order of elements

Posted: Fri Dec 02, 2011 5:33 am
by Rakesh123
Hi,
I am trying to verify the sorting order of the tree items included in panel using ranorex code(C#).

Thanks,
Rakesh

Re: Verify order of elements

Posted: Fri Dec 02, 2011 3:17 pm
by Support Team
Hi,

I think the following code provides the needed functionality:
var yourVar = repo.YourElement.TheParentElement;
      IList<ListItem> list = TheParentElement.FindChildren<ListItem>();
      
      int i = 0;
      bool rightOrder = true;
      String[] checkText = new String[3];
      checkText[0] = "YourText1";
      checkText[1] = "YourText2";
      checkText[2] = "YourText3";

      foreach(ListItem item in list){
        
        if(item.Text!=checkText)
          rightOrder= false;
        
        i++;
      }
      
      if(rightOrder)Report.Info("Right order!!!");


Regards,
Markus
Ranorex Support Team

Re: Verify order of elements

Posted: Sun Jul 15, 2012 1:22 pm
by Rakesh123
Hi Marcus,

The code provided by you was very good.

But I have small problem with that.

Like you have mentioned,you assigned the items order in an string array & with each element in the list u r comparing with the 1st,2nd,3rd item in an array.

So assume that i compared the first element of the list with first element in an array.It matched and 'rightOrder' will be 'true'

Similarly
2nd element from List-->2nd element from array-->Result is false
3rd element from List-->3rd element from array-->Result is true

So at last false value is overriden by true & the result will be displayed as 'Right Order'

Thanks,
Rakesh

Re: Verify order of elements

Posted: Mon Jul 16, 2012 8:20 am
by artur_gadomski
No it won't. Default value is true and it will be overwritten only if one of the values don't match. In your example it will be as follows:
start
right order = true
1st item (match) - no change to right order
2nd item (no match) - right order = false
3rd item (match) - no change to right order

at the end right order is false.