Page 1 of 1

Pass null value in data driven test

Posted: Wed Apr 29, 2015 2:36 pm
by Vaughan.Douglas
I'm working with a series of data driven tests that are checking that values entered by one user/user class are or are not visible to another user/user class.

In one case the innertext attribute is holding null and my Excel value is of course holding and empty string. This is a modular build so I'm using the same module to validate across multiple scenarios. Is there a keyword I can use in Excel that Ranorex will interpret as null?
check for null.png

Re: Pass null value in data driven test

Posted: Wed Apr 29, 2015 4:17 pm
by krstcs
Excel can't output null.

One thing you can do, instead, is to right-click the action that is causing issues and convert it to user-code. Then you can manipulate the values in code such that if one value is null, you set it to "" (Empty string), and then compare the two strings.

Code: Select all

string myString = originalString == null ? "" : originalString; //condensed "if" statement of the following:
//if (orginalString == null) {
//  myString = ""; 
//} else {
//  myString = originalString;
//}

if (myString.Equals(excelString)) {
  //do your stuff here...
}

Re: Pass null value in data driven test

Posted: Wed Apr 29, 2015 4:50 pm
by Vaughan.Douglas
I appreciate the response. Unfortunately I'm avoiding user code at all costs to encourage my less technical users to own this automation suite.

I will need to explain that either they will not be able to check for the null value or we'll have to allow for some user code. I'm sure they'll get over it.

Re: Pass null value in data driven test

Posted: Wed Apr 29, 2015 8:05 pm
by krstcs
From my experience/opinion, even with Ranorex, as good as they are at keeping things simple, you are still building a piece of software, so anyone doing it needs to understand the process. Test automation is not for non-technical people, as much as companies that make the automation tools try to say it can be. The Ranorex team does a great job and builds the best product on the market, but it is still software development at its core. Non-technical people need to become technical if they want to keep up the tests. There are always situations like yours where you have to find a technical solution.


Having said that, the best way I have found to keep the less technical people happy is to create your modules so that they don't have to look inside them. Make them small and atomic (single action).

For example, if you need to click the 'OK' button, make a module called 'Click_OKButton' and the only thing in it is the click action on the OKButton repo item.

Same thing for entering text in a textbox. Name it 'Enter_UserName' and pass the variable 'UserName' to it. Then all you should do in the module is click the field, enter the name, and validate that the value is in the field.

Then, your non-technical users can just drag and drop the modules (think of them as modular test steps) into the test suite/case where they need it. They will need to learn about binding data to variables, but this is a technical project.

Hope that helps!

Re: Pass null value in data driven test

Posted: Thu Apr 30, 2015 12:08 pm
by Vaughan.Douglas
krstcs wrote:From my experience/opinion, even with Ranorex, as good as they are at keeping things simple, you are still building a piece of software, so anyone doing it needs to understand the process. Test automation is not for non-technical people, as much as companies that make the automation tools try to say it can be. The Ranorex team does a great job and builds the best product on the market, but it is still software development at its core. Non-technical people need to become technical if they want to keep up the tests. There are always situations like yours where you have to find a technical solution.


Having said that, the best way I have found to keep the less technical people happy is to create your modules so that they don't have to look inside them. Make them small and atomic (single action).

For example, if you need to click the 'OK' button, make a module called 'Click_OKButton' and the only thing in it is the click action on the OKButton repo item.

Same thing for entering text in a textbox. Name it 'Enter_UserName' and pass the variable 'UserName' to it. Then all you should do in the module is click the field, enter the name, and validate that the value is in the field.

Then, your non-technical users can just drag and drop the modules (think of them as modular test steps) into the test suite/case where they need it. They will need to learn about binding data to variables, but this is a technical project.

Hope that helps!
You're preaching to the choir here. This is definitely a special case. We're actively bringing our QA community which we consider "non-technical" into the automation space. Some folks are just going nuts with the new tools and others think we're out trying to cut them out of a job.

I'm still very new to Ranorex but I've been doing automation for years. I'm very comfortable in .Net so the urge to solve all my problems by incorporating user code is pretty strong. I'm forcing myself to solve challenges using the capabilities Ranorex provides out of the box.

In the case of the null value, it isn't a limitation on Ranorex, but an Excel limitation that's causing my module to be incompatible with the stated test goals. Which actually brings me to another point... this whole thing isn't really an issue because they don't "REALLY" want to check for a null value. The fact of the matter is the element holding the string isn't even displayed when there is a null value.

Thanks for the advise. I'll be sure to put it to good use.

Re: Pass null value in data driven test

Posted: Thu Apr 30, 2015 1:21 pm
by krstcs
You're welcome! I'm in about the same boat you are. I've done automation for years and actual Java and .NET coding in between. I've been using Ranorex for a while now though and it is an incredible system.