Accessing a "Cell" and its children

Mobile Testing, Android App Testing.
mattmccall
Posts: 34
Joined: Mon Nov 12, 2012 8:13 pm

Accessing a "Cell" and its children

Post by mattmccall » Fri Mar 08, 2013 4:53 pm

I am testing a iOS app that has a screen that has different cells on it and I want to click the right cell. The cells have names that can be dynamic so I want to make sure I click the correct cell.

The object looks like this:
/mobileapp/form/container/container/container/ioselement/cell/cell[@accessibilitylabel='Member:Dog, Droopy']

if there is more than one the other cells look like this:
/mobileapp/form/container/container/container/ioselement/cell[2]/cell[@accessibilitylabel='Member:Hound, Huckleberry']
/mobileapp/form/container/container/container/ioselement/cell[3]/cell[@accessibilitylabel='Member:McGraw, QuickDraw']

I am having trouble trying to access the correct cell. I want to loop through the cells, check to see if the attribute of accessibilitylabel is the one I want and then click it.

I made my object be /mobileapp/form/container/container/container/ioselement/cell in my repository and when i did:
obj.Children.Count

I got a count of 3 so I appear to be on the correct path here. I then I tried to put the items in a list so I could check them:

Ranorex.Cell List = obj;
IList<Unknown> cells = List.FindChildren<Unknown>(".//Cells");

When I do a count on 'cells' I get 0 items in the list.

I have tried many combinations of the list above to no avail. I have also tried to set the object to /mobileapp/form/container/container/container/ioselement/. in the repository and I still get the same results.

Has anyone else tried to do something like this, or see the errors in my ways?

Matt

mattmccall
Posts: 34
Joined: Mon Nov 12, 2012 8:13 pm

Re: Accessing a "Cell" and its children

Post by mattmccall » Fri Mar 08, 2013 5:10 pm

I figured this out. I am just changing the object on the fly to what ever cell I want and then check the attribute (duh!)

for (int y = 1, y < 4, y++){
Ranorex.Cell cellList = "/mobileapp/form/container/container/container/ioselement/cell[" +"y"+"]/cell";
// get the attribute level
// check to see if it is the one i want
// if it is the one i want, click it
// exit loop
}

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

Re: Accessing a "Cell" and its children

Post by Support Team » Mon Mar 11, 2013 4:53 pm

Hi,

Good to know that you were able to solve the issue :).
You could also use the following RxPaths in order to identify a cell with a specific attribute:
Ranorex.Cell myCell = "/mobileapp/form/container/container/container/ioselement/cell/cell[@accessibilitylabel='Member:Hound, Huckleberry']";
//OR
Ranorex.Cell myCell = "/mobileapp/form/container/container/container/ioselement//cell[@accessibilitylabel='Member:Hound, Huckleberry']";
these RxPaths should identify a cell with the "accessibilitylabel" attribute set to "Member:Hound, Huckleberry", if this is a unique attribute.
Here are two useful links to articles about the RxPath:
RanoreXPath
RanoreXPath – Tips and Tricks
I hope the articles are of use.

Regards,
Markus

mattmccall
Posts: 34
Joined: Mon Nov 12, 2012 8:13 pm

Re: Accessing a "Cell" and its children

Post by mattmccall » Tue Mar 12, 2013 2:44 pm

Thanks for the extra info Markus!