ScrollTable ranorex With iOS

Mobile Testing, Android App Testing.
bide1
Posts: 1
Joined: Tue Jul 28, 2015 11:27 am

ScrollTable ranorex With iOS

Post by bide1 » Tue Jul 28, 2015 11:43 am

Hello, everyone
Sorry before my english is not good

I'm testing a app IOS, and i used IosTable for scroll a list.
a path of a cell in list : /mobileapp[@title='nameapp']/form/?/?/container[@containertype='ViewControllerWrapper']//table/container[1]/container[2]/cell[@accessibilitylabel='54+T4+ N° :+Niv. :+1+ABARCA Christian+Vacant+']
with @accessibilitylabel is text in this cell

Problem, i can scroll to each cell. I can get path of each cell and string of each cell too.
Par exemple :
i get path a cell, I recived : /mobileapp[@title='nameapp']/form/?/?/container[@containertype='ViewControllerWrapper']//table/container[1]/container[1]/cell[@accessibilitylabel='3+T3+ N° :+Niv. :+3+ABRAHAM Stephane+Vacant+']
string of cell : Cell:3+T3+ N° :+Niv. :+3+ABRAHAM Stephane+Vacant+

But now, I want to touch() on this cell
i was try :

Ranorex.Cell cell = repo.nameapp.Self.FindSingle<Ranorex.Cell>(path); // path of a cell
cell.touch();
but it's seem not good.
Can you help me ? Please
Or you can propose different methode.

Thank you very much

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: ScrollTable ranorex With iOS

Post by Support Team » Thu Aug 13, 2015 11:05 am

Hi all,

bide1 contacted us via email and we found a solution for this issue.

Enclosed you can find a general code sample about how to scroll and search for a specific item within an iOS-table.

The list which was used for the sample, contains names which are divided into different sections (A - Z).

Prerequisites for using the code sample are two repository elements:
*) The table-element which contains all the cells
*) A repository element which represents the current cell. Within the RanoreXPath of the element we use a variable to identify the element according to the searched name (http://www.ranorex.com/support/user-gui ... html#c2970)

First, add the following method to the user code file of your recording (*.UserCode.cs).
ScrollAndClick.cs
(1.32 KiB) Downloaded 74 times

Code: Select all

public void ScrollAndClick(Ranorex.Adapter table, Ranorex.Adapter cell, Ranorex.Core.Repository.RepoItemInfo cellInfo, Duration searchTimeout)
{
    //Variable which indicates if the element was found
    bool found = false;
        	
    //Store number of rows per section to string array
    string[] numberOfRowsString = table.As<IosTable>().NumOfRowsPerSection.Trim('[',']').Split(',');
        		
    //Loop through sections
    for ( int section = 0; section <= table.As<IosTable>().NumOfSections && found==false; section++ )
    {
        int currentNumberOfRows = Int32.Parse(numberOfRowsString[section]);
        		
        //Loop through rows within current section
        for ( int row = 0; row <= currentNumberOfRows && found == false; row+=25)
        {
        	//Perform scroll action
        	Report.Info("Scroll to row: "+row+", section: "+section);
        	table.As<IosTable>().ScrollTable(section,row);
        			
        	//Check if the item exists within visible area
        	found = cellInfo.Exists(searchTimeout);
        			
        	//Perform a touch action if the item was found
        	if ( found == true )
        	{
        		Report.Info("Found element "+cell.ToString()+", perform touch-action");        				
        		cell.Touch();
        	}       
        }
        		        		
    }
}
You are now able to add this method to your action table.
add_user_code_method.png
add_user_code_method.png (38.63 KiB) Viewed 863 times
Four parameters have to be passed to the method.
1) Drag and drop the corresponding table element to the parameter 'table (Adapter)'
2) Drag and drop the cell element to the parameter 'cell (Adapter)'
3) Drag and drop the cell element to the parameter 'cellInfo (RepoItemInfo)'
4) Enter a value for the 'searchTimeout'. Depending on the processing power of your machine, you probably need a higher search timeout.
add_parameters.png
add_parameters.png (31.47 KiB) Viewed 863 times
add_parameter_search_timeout.png
add_parameter_search_timeout.png (21.64 KiB) Viewed 863 times
Now you should be able to scroll your list and click on a specific element.

Note that the sample probably needs to be adjusted depending on your application and your needs.

Regards,
Johannes
.
Image