How to use null values in a datadriven approach (xsi:nil="true") from an Excel datasource?
We have a request that needs to pass a null value in a particular scenario. Our requests have an Excel datasource that we use for parameters.
The issue we have, is that we are unable to parametize the null value in excel, it simply does not work., we get the error: "cvc-type.3.1.3: The value 'xsi:nil="true"' of element 'AccountNumber' is not valid"
When we use the notation below, it works properly, but in this case we are not using the datasource
<AccountNumber xsi:nil="true"/>
When we use the datasource, the notation changes to;
<AccountNumber>${DataSourceTestCases#LOI_ACC_AccountNumber0}</AccountNumber>
Using the datasource causes the error already mentioned
"cvc-type.3.1.3: The value 'xsi:nil="true"' of element 'AccountNumber' is not valid"
How can we parametize the null value from an excel datasource?
We are using ReadyAPI 2.5.0
Clemente
Hi richi and everyone else;
I have to thank you all for you suggestions I appreciate them. Your ideas guided me towards the solution that I needed. Now it is working. I ended up using the “RequestFilter.filterRequest” as I had to change the request values before submitting it. (not the response, sorry if I did not explained this properly earlier)
Our request data is read from a datasource, sometimes we need to use null values to test different scenarios.
The idea is to replace a null string representation fed through a data source for the actual null that ready api uses. This needs to be done for every node that needs it before submitting the request
.
So, if we have a request has two or five or more nodes that need to send a null value equivalent then, this solution applies no matter the node name, it should work also at any level in the hierarchy, but I have not tested this yet
The objective if to search for the string representing null, in my case it is “>xsi:nil="true"</TagName> using regular expression to target any tagname
The solution consist in creating a RequestFilter.filterRequest and add the following code:
def reqContent = context.requestContent
def contentlog.info(reqContent)
content = reqContent.replaceAll(">xsi:nil=\"true\"</[A-Za-z]+>", " xsi:nil=\"true\" />")
context.requestContent = content
log.info(content)
Cheers!!!