Pass null value in data driven test

Best practices, code snippets for common functionality, examples, and guidelines.
Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Pass null value in data driven test

Post by Vaughan.Douglas » Wed Apr 29, 2015 2:36 pm

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
check for null.png (25.81 KiB) Viewed 1665 times
Doug Vaughan

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Pass null value in data driven test

Post by krstcs » Wed Apr 29, 2015 4:17 pm

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...
}
Shortcuts usually aren't...

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Pass null value in data driven test

Post by Vaughan.Douglas » Wed Apr 29, 2015 4:50 pm

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.
Doug Vaughan

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Pass null value in data driven test

Post by krstcs » Wed Apr 29, 2015 8:05 pm

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!
Shortcuts usually aren't...

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Pass null value in data driven test

Post by Vaughan.Douglas » Thu Apr 30, 2015 12:08 pm

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.
Doug Vaughan

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Pass null value in data driven test

Post by krstcs » Thu Apr 30, 2015 1:21 pm

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.
Shortcuts usually aren't...