Problems with the function ScrollTable()

Mobile Testing, Android App Testing.
JToelstede
Posts: 55
Joined: Fri May 24, 2013 12:57 pm

Problems with the function ScrollTable()

Post by JToelstede » Thu Jan 09, 2014 12:20 pm

Hi,

I have some problems with the function ScrollTable() and need some help!

In our app we have a table where every cell represents a file.
My test case is to verify that every file in the table can be opened.
It is possible that the table contains different sections and each displayed section has at least one file entry.

I wrote a function in my usercode that opens every displayed item and I use the scrollTable()-function to get the next item if it isn't displayed
The problem occurs after the second scroll because the ranorex-index of the cells has changed.

I wrote a sample app with a MasterDetailView with 25 menu items. When I start the app the menu contains 16 visible items.
After the first call of scrollTable() I see the next item and I could tap on the item.
After the second call of scrollTable() the ranorex-index of the displayed items changed and I couldn't tap the item which should be the next to open.

Why does the ranorex-index change after the second scroll?
Do you have any idea to solve the problem?

Here is my usercode:

Code: Select all

public void TouchEveryItemWithScrollingAfterLastDisplayedCellIsReached()
{
  var adapter = repo.SimpleMasterDetailApp.EmptyList.As<Ranorex.IosTable>();
  int sections = adapter.NumOfSections;
  int shownRows = repo.SimpleMasterDetailApp.EmptyList.Find<Cell>("./container/cell", 1000).Count;
  char[] delimiters = new char[] { '[', ']', ',', ' '};
  int[] rowsPerSection = tointarray(adapter.NumOfRowsPerSection, delimiters);
        	
  Report.Info("Cound of displayed cells: " + shownRows);
  for(int sektionidx = 0; sektionidx < sections; sektionidx++)
  {
    int rowsInCurrentSection = rowsPerSection[sektionidx];
    int scrollidx = 1;
    
    for(int rowidx = 1; rowidx <= rowsInCurrentSection; rowidx++)
    {
       if(rowidx > shownRows)
  	{
  	  scrollidx++;
  	  adapter.ScrollTable(sektionidx, scrollidx);
  	  Report.Info(string.Format("Called ScrollTable({0},{1})",sektionidx, scrollidx));
  	}
					
  	var aktItem = repo.SimpleMasterDetailApp.EmptyList.FindSingle(string.Format(".//cell[{0}]/container/cell[1]", rowidx));
  	Touch.Tap(aktItem);
  	Report.Info("current element: " + repo.SimpleMasterDetailApp.LabelDetailView.Element.GetAttributeValueText("caption"));
     	}
    }
 }

public int[] tointarray(string value, char[] seperator)
{
  string[] stringArray = value.Split(seperator, StringSplitOptions.RemoveEmptyEntries);
  int[] intArray = new int[stringArray.Length];
  for (int i = 0; i < intArray.Length; ++i)
  {
    int j;
    string s = stringArray[i];
    if (int.TryParse(s, out j))
    {
      intArray[i] = j;
    }                 
  }
  return intArray;
}
I use Ranorex 4.1.3 with the libRxAutomationUni_413.a.
The test device is an iPad with iOS 7.0.4.

Thanks a lot.
Best Regards,
Joerg

User avatar
mebner
Posts: 61
Joined: Tue Dec 17, 2013 6:42 pm

Re: Problems with the function ScrollTable()

Post by mebner » Thu Jan 09, 2014 5:59 pm

Hi Joerg,

This is because of the scrolling. The "[]"- index just indexes the visible elements and when for instance the first item is no longer displayed, because of the scroll, the second item gets the index one, because it is now the first visible item of the table.

You need to reset the row- counter (rowidx) after you scrolled the table to a specific item.

Regards,
Markus

JToelstede
Posts: 55
Joined: Fri May 24, 2013 12:57 pm

Re: Problems with the function ScrollTable()

Post by JToelstede » Mon Jan 13, 2014 10:19 am

Dear Markus,

thanks for your answer.

Because of your answer I have an other question. What does "visible" mean in this context.
Does visible mean the table cells which are visible for the user or did you mean displayed but with the possibility that some cells are not visible for the user because they are displayed under the table header?

I wrote a sample app with a MasterDetailView. The MasterView is a table with 25 menu items. In the DetailView is a label which represents the name of the touched item of the MasterView.
When you scroll the first time the first table cell is still displayed under the header of the MasterView but it is not visible for the user and you are not able to touch on it with Ranorex. The attribute "visible" in Ranorex is true for this item.
After the second scroll one-quater of the first cell and the second cell are displayed under the table header but not visible for the user. At this point the index is still correct and the attribute "visible" in Ranorex is true for both items.
After the third-scroll the first-cell is not displayed anymore and one-quater of the second-cell and the third-cell are displayed under the table header of the MasterView and now the index changed.
I mad a picture of the table and the behavior of the table during the scrollTable function in the sample app.
scrollTable_problem.png
scrollTable_problem.png (179.88 KiB) Viewed 1395 times
In your post you wrote that I have to reset my row-counter. Please could you post an example because I tried to do this before I opened this post but it does not work.


Thank you!

Regards,
Joerg
Attachments
SimpleMasterDetailApp.zip
SimpleMasterDetail xCode-project
Before running the project you have to add the RanorexAgentLib.
(84.54 KiB) Downloaded 142 times

User avatar
mebner
Posts: 61
Joined: Tue Dec 17, 2013 6:42 pm

Re: Problems with the function ScrollTable()

Post by mebner » Fri Jan 17, 2014 9:59 am

Hi Joerg,

I created a small sample.
I used an internal app, which contains a table, which consists of 5 sections, and each section includes 5 cells.
In my case 20, respectively 21, cells are visible at once.
The click algorithm needs to be split in three sections.
In the first section, I just click on the first two cells.
In the second section, I click the cells which are in a region of the table which needs to be scrolled, to show the not visible cells, and in the third, I click on the remaining ones, which can be displayed at once (no scroll is needed).
The code shows how this could work.
var emptyList = repo.YourTable.As<Ranorex.IosTable>();

			
			// you need to get the following information, in my case it is hard coded, but you can also calculate it
			int cells = 35;	
			int section = 6;	
			int cellsinsection= 5;
			int visiblecells = 20;
			
			// the first two cells need to be clicked outside the for
			emptyList.ScrollTable(0,0);
			emptyList.FindSingle<Ranorex.Cell>(".//cell[1]").Touch();
			Delay.Duration(1000);
			emptyList.FindSingle<Ranorex.Cell>(".//cell[2]").Touch();
			emptyList.ScrollTable(0,2);
			int clickedCells = 2;
			
			// the first cells will be clicked here, the scroll is also needed
			for(int s=0; s<section; s++)
			{
				for(int a=0; a<cellsinsection; a++)
				{
					if(clickedCells==(cells-visiblecells))break;
					
					if(s==0 && a==0){
						a=2;
					}else{
						emptyList.FindSingle<Ranorex.Cell>(".//cell[2]").Touch();
						emptyList.ScrollTable(s,a);
						clickedCells++;
					}

				}
			}
			
			// clicking of the remaining cells, the table doesn't need to be scrolled
			IList<Cell> remainingcells = emptyList.Find<Ranorex.Cell>("./cell");
			Boolean first = true;
			foreach(Cell cell in remainingcells){
				
				if(!first){
					cell.Touch();
				}else{
					first = false;
				}
				
			}
Regarding the question about the visible elements, I meant the elements which can be seen by the user and the one which is displayed under the table’s header. As soon as the table is scrolled, the not yet visible cells will be realized too.

Regards,
Markus

JToelstede
Posts: 55
Joined: Fri May 24, 2013 12:57 pm

Re: Problems with the function ScrollTable()

Post by JToelstede » Tue Jan 21, 2014 9:03 am

Hi Markus,

first of all sorry for the belated answer.
After some changes to get your example dynamic the source code is working fine.

Thanks a lot. for your work.

Best regards
Joerg