Repository variable not updating

Ask general questions here.
jack
Posts: 3
Joined: Sun Oct 16, 2016 9:23 pm

Repository variable not updating

Post by jack » Mon May 15, 2017 4:57 pm

Hello,

My overall goal is to validate a column in a table. The number of rows in the column changes so this is my attempt. rowNum is a defined repository variable that is in the repository item which I pass to the parameters repoItem and adapter.
The repository item looks like: .//table/tbody/tr[$rowNum]/td[3]/a

Code: Select all

public void Validate(RepoItemInfo repoItem, Adapter adapter)
        {
        	int row = 2;
        	repo.rowNum = "" + row;
        	
        	while (repoItem.Exists(2000)) {        		
        		string input = "";
        		
        		adapter.MoveTo(); 
        		input = adapter.Element.GetAttributeValueText("InnerText");
	
        		Report.Log(ReportLevel.Info, "Status", "Row input: " + input);
        		        		      		
        		row++;
        		repo.rowNum = "" + row;
        	}
        }
It correctly identifies the number of rows in the table and the while loop executes the correct number of times but MoveTo() and GetAttributeValueText() always execute on the first row. So it seems that the repoItemInfo is updating correctly but the repoItem itself is not?

When I am more explicit and do something like:

Code: Select all

public void ValStartsWithLastName(RepoItemInfo repoItem)
        {
        	int row = 2;
        	repo.rowNum = "" + row;
        	
        	while (repoItem.Exists(2000)) {
        		        		
        		string input = "";
        		
        		repo.MyApp.myRepositoyItem.MoveTo(); 
        		input = repo.MyApp.myRepositoyItem.Element.GetAttributeValueText("InnerText");
        			
        		Report.Log(ReportLevel.Info, "Status", "Row input: " + input);
        	        		
        		row++;
        		repo.rowNum = "" + row;
        	}
        }
The repository item updates correctly here but I would like to be able to validate different columns in various tables (which have different paths) so I can't use this solution.

Thanks in advance

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Repository variable not updating

Post by odklizec » Tue May 16, 2017 7:12 am

Hi,

Please post a Ranorex snapshot of the problematic table. Ideally, post also a small sample HTML code, featuring your table. This way we can easily try your code along with the table and without the need to re-create the table from scratch. Thanks.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration