Validation

Ask general questions here.
ThN
Posts: 15
Joined: Fri Jun 15, 2012 2:12 pm

Validation

Post by ThN » Thu Jun 21, 2012 8:15 am

Hello,

I am testing a Windows form applciation. It containse a List Box. The test is to check the proper loading of the List Box. I loop through each item of list box to ensure the proper expected item. The problem here is that if the first item fails to validate the test ends. But in the previous version of Ranorex it was displaying the validation results of all the item. Here as the test stops at the first item it failed. I need test to proceed n display the results for rest of the items. Can anyone suggest me with the solution so the I can see exactly which item is not matching with the expected.

Thanks
ThN

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

Re: Validation

Post by Support Team » Thu Jun 21, 2012 10:16 am

Hi,

can you please provide us some more information about the way you are going to validate the list items?
Are you looping over the items using user code, or do you use the data driven approach?
If you are performing your validation via user code, can you provide us the code?

Regards,
Tobias
Ranorex Team

ThN
Posts: 15
Joined: Fri Jun 15, 2012 2:12 pm

Re: Validation

Post by ThN » Thu Jun 21, 2012 12:38 pm

Hi,
Thanks for the reply, Here is my code

Code: Select all

  	Table table = "/form[@controlname='GraphicalModelConnectionDemoForm']/container/container[@controlname='panel2']/container/element/container/container/container/container/container[@controlname='panel1']/element/table[@controltypename='NListView']";
        	
// Here I check that all the expecte data is loaded
        	Validate.AreEqual(table .Rows.Count, _ExpectedListOfModels.Count);
        	
        	foreach(Row item in table .Rows)
        	{
        		Validate.IsTrue(_ExpectedListOfModels.Contains(item.Cells[0].Text));
        	}
In the above code, ExpectedListOfModels is a List<string>. As I am beginner of Ranorex I haven't explored Data driven approach yet. Here I use imlpementation of ITestModule and create my test in the method Run().

Kind regards

ThN

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

Re: Validation

Post by Support Team » Thu Jun 21, 2012 1:12 pm

Hi,

basically you can use an overload of the IsTrue validation where you can specify whether an exception should be thrown or not:
IsTrue(condition,message,exceptionOnFail)

So, the call should look something like this:
Validate.IsTrue(_ExpectedListOfModels.Contains(item.Cells[0].Text), "Some Text", false);
Regards,
Tobias
Ranorex Team

ThN
Posts: 15
Joined: Fri Jun 15, 2012 2:12 pm

Re: Validation

Post by ThN » Fri Jun 22, 2012 9:41 am

Thanks,

Kind regards,

ThN