Condition XPath Expression in SoapUI - how to compare two values stored in custom properties? - testing

I have successfully captured four values from a response. I need to check that none of them are the same as any other (without worrying about every combination). In theory, checking that Value1 <> Value2, Value2 <> Value3, Value3<> Value4 are all true.
I could go with a mathematical identity approach (eg where Value1/Value2*Value2/Value3*Value3/Value4 = 0). I am failing in what I actually put in the body of the Condition XPath Expression in SoapUI (and the help is woeful, as always). Pretty sure I don't need to worry about the namespace stuff.
Right now I have three separate conditions eg ${#TestCase#Value1} <> ${#TestCase#Value2} but I am getting a "no condition is true for current response" message when I know that 3 of the four are true.
Also, if the condition I am looking for is true, I need to halt, or pop to a step that does nothing. Any ideas on that?
Full current entry in the Condition XPath Condition box is:
declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://transferobjects.abc.def.org.nz';
declare namespace ns2='http://abc.def.org.nz/api/serviceorder';
${#TestCase#Value1} <> ${#TestCase#Value2}
(but I am pretty sure the first three lines aren't even needed because I am not getting anything from the message response, I have captured those already into the valueX items above).

Related

Difference between sequential and combined predicates

In Selenium I have written a xpath and both of them retrieves the same result.
//a[#role='tab'][text()=' Assets']
//a[#role='tab' and text()=' Assets']
Does both of them have the same meaning?
In most cases a[b][c] has exactly the same effect as a[b and c]. There are two exceptions to be aware of:
They are not equivalent if either predicate is numeric, or has a dependency on position() or last() (I call these positional predicates). For example a[#x][1] selects the first a element that has an #x attribute, while a[1][#x] selects the first a element provided it has an #x attribute (and selects nothing otherwise). By contrast a[1 and #x] converts the integer 1 to the boolean true(), so it just means a[#x].
There may be differences in behaviour if evaluation of b or c fails with a dynamic error. The precise rules here depend on which version of XPath you are using, and to be honest the rules leave implementations some leeway, but you need to exercise care if you want to be sure that in the event of b being false, c is not evaluated. (This hardly matters in XPath 1.0 because very few expressions throw dynamic errors.)
When you add Square Brackets ([]) to XPath you are adding a condition, so
first row adding 2 conditions
Which produce similar results as adding condition with and
Normally you don't use first row, because it less readable,
Mainly because this syntax represent in other languages a Matrix
// return a random m-by-n matrix with values between 0 and 1
public static double[][] random(int m, int n) {
See tutorial:
5 XPaths with predicates
A predicate is an expression that can be true or false
It is appended within [...] to a given location path and will refine results
More than one predicate can be appended to and within (!) a location path
The first one is a predicate, which means it checks if a[#role='tab'] is true then it proceeds to [text()=' Assets']
The second one is a just using an and operator so it validates both are true.

How to break RegexMatcher loop

The first image below is the parent workflow and the image below that is the child workflow. In the child workflow I check if a singular value I provide is in the list separated by commas I also provide. I use a Regex matcher along with an if node to do this. The problem is the Regex matcher continues to execute for all matches although I want it to stop checking # 2016/05/13 09:08:30, when the expression evaluates to true (the word 'Contract' is present in 'Contract,VMS,Payroll'). I want the Regex matcher to stop and then output isTrue boolean to the variable bar so the parent workflow gets a 'true' instead of the false which it gets now. (which you can see happens in the last activity entry 2016/05/13 09:08:30 where Value is false (since it gets the LAST updated value) for the child workflow).
Hmmm..... There isn't a way to break out of that loop but you should be able to use Regex Match One instead of the loop version as you're actually only interested in determining whether a given pattern matches rather than needing to iterate over each match in order to process it further.
Yes or if its really just s simple string match, use the If Node with expression 'Value like "matchexpression" '

Use String for IF statement conditions

I'm hoping someone can help answer my question, perhaps with an idea of where to go or whether what I'm trying to do is not possible with the way I want to do it.
I've been asked to write a set of rules based on the data held by our ERP form components or variables.
Unfortunately, these components and variables cannot be accessed or used outside of the ERP, so I can't use SQL to query the values and then build some kind of SQL query.
They'd like the ability to put statements like these:
C(MyComponentName) = C(MyOtherComponentName)
V(MyVariableName) > 16
(C(MyComponentName) = "") AND V(MyVariableName) <> "")
((C(MyComponentName) = "") OR C(MyOtherComponentName) = "") AND V(MyVariableName) <> "")
This should be turned into some kind of query which gets the value of MyComponentName and MyOtherComponentName and (in this case) compares them for equality.
They don't necessarily want to just compare for equality, but to be able to determine whether a component / variable value is greaterthan or lessthan etc.
Basically it's a free-form statement that gets converted into something similar to an IF statement.
I've tried this:
Sub TestCondition()
Dim Condition as string = String.Format("{0} = {1}", _
Component("MyComponent").Value, Component("MyOtherComponent").Value)
If (Condition) Then
' Do Something
Else
' Do Something Else
End If
End Sub
Obviously, this does not work and I honestly didn't think it would be so simple.
Ignoring the fact that I'd have to parse the line, extract the required operators, the values from components or variables (denoted by a C or V) - how can I do this?
I've looked at Expression Trees but these were confusing, especially as I'd never heard of them, let alone used them. (Is it possible to create an expression tree for dynamic if statements? - This link provided some detail on expression trees in C#)
I know an easier way to solve this might be to simply populate the form with a multitude of drop-down lists, so users pick what they want from lists or fill in a text box for a specific search criteria.
This wouldn't be a simple matter as the ERP doesn't allow you to dynamically create controls on its forms. You have to drag each component manually and would be next to useless as we'd potentially want at least 1 rule for every form we have (100+).
I'm either looking for someone to say you cannot do this the way you want to do it (with a suitable reason or suggestion as to how I could do it) that I can take to my manager or some hints, perhaps a link or 2 pointing me in the right direction.
If (Condition) Then
This is not possible. There is no way to treat data stored in a string as code. While the above statement is valid, it won't and can't function the way you want it to. Instead, Condition will be evaluated as what it is: a string. (Anything that doesn't boil down to 0 is treated as True; see this question.)
What you are attempting borders on allowing the user to type code dynamically to get a result. I won't say this is impossible per se in VB.Net, but it is incredibly ambitious.
Instead, I would suggest clearly defining what your application can and can't do. Enumerate the operators your code will allow and build code to support each directly. For example:
Public Function TestCondition(value1 As Object, value2 As Object, op as string) As Boolean
Select Case op
Case "="
Return value1 = value2
Case "<"
Return value1 < value2
Case ">"
Return value1 > value2
Case Else
'Error handling
End Select
End Function
Obviously you would need to tailor the above to the types of variables you will be handling and your other specific needs, but this approach should give you a workable solution.
For my particular requirements, using the NCalc library has enabled me to do most of what I was looking to do. Easy to work with and the documentation is quite extensive - lots of examples too.

Adobe Livecycle: how to get the value of process data

I have a process data defined in Adobe livecycle, addField as a string. I am passing the value of this variable as an input when i invoke a process. Further i want to compare the value of this process data if it is true or false. I am trying to use the following expression:
string(/process_data/#addField)=string("true")
but i am not getting the value out of the expression. Is the above expression true? If not what is used to get the value of the process data?
I believe your XPath expression is wrong. I just did a quick mock-up in workbench and I got the correct response. Here are the details of what I did:
Created an input string variable i workbench called addField.
Created a two step process. The first step has two routes going out to two different set values.
On one of the routes, I added the following condition:
/process_data/#addField = "true"
Turned on recording, and invoked the process.
In the input parameters screen in workbench, I added the following text: true
In the recording, I can see the expression evaluating correctly and going to the correct set value.
Do let me know if you have any other questions.
Thanks,
Armaghan.

In SSRS, how do I make a drop-down parameter visible only if a previous parameter has one option chosen?

I have a situation where I want to make a drop-down parameter visible only if a previous multi-drop-down param. has one choice chosen(out of many choices).
Wht i've triedso far is to set the Default Val. for the drop-down parameter to be this:
=iif( Parameters!AccountIDs.Count >0 , 1, Nothing)
But it's not working. any tips appreciated, thanks
You won't be able to make a parameter disabled or enabled like this. (At least not without getting really complicated and hacking the page a bunch)
But you can make the second parameter have dynamic available options. Then make it just a sinlge option such as "<Not applicable>" and select that if the earlier parameter has multiple values.
You will need to create a dataset that returns the available parameters. Something like this might work:
SELECT
'<Not Applicable>' AS ParameterValue
WHERE
#ParamOneCount > 1
UNION ALL
SELECT
SourceName
FROM
someTable
WHERE
#ParamOneCount = 1
(You could change replace the second SELECT with multiple selects to have multiple hard coded values.) Then in the parameters for this dataset, set one of the parameters to be called "ParamOneCount" and set its value to be =Parameters!Account.Count