Verify order of elements

Class library usage, coding and language questions.
Rakesh123
Posts: 72
Joined: Thu Oct 28, 2010 2:18 pm

Verify order of elements

Post by Rakesh123 » Thu Dec 01, 2011 3:12 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Verify order of elements

Post by Support Team » Thu Dec 01, 2011 9:50 am

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

Rakesh123
Posts: 72
Joined: Thu Oct 28, 2010 2:18 pm

Re: Verify order of elements

Post by Rakesh123 » Fri Dec 02, 2011 5:33 am

Hi,
I am trying to verify the sorting order of the tree items included in panel using ranorex code(C#).

Thanks,
Rakesh

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Verify order of elements

Post by Support Team » Fri Dec 02, 2011 3:17 pm

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

Rakesh123
Posts: 72
Joined: Thu Oct 28, 2010 2:18 pm

Re: Verify order of elements

Post by Rakesh123 » Sun Jul 15, 2012 1:22 pm

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

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

Re: Verify order of elements

Post by artur_gadomski » Mon Jul 16, 2012 8:20 am

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.