Cucumber - Can`t retrieve parameter value using .yaml file - cucumber-java

I need to pass multiple parameters in cucumber, one of them are path parameter, and second is query parameter.
Both values are stored in .yaml file, but when Im passing parameter through data table, Cucumber resolving it and Im getting a value. However I need to pass path parameter right to the step definition.
Is it possible?
I`ve been searching in Cucumber doc and it seems like not.
Example of my step definition:
Given Send some request with specified item "${something.custom.path-parameter}" and query parameter
| query_parameter | ${value} |

Related

JDBC variable names when called in the groovy script not giving the correct value for a CSV parameterization

I have a JMeter test where a CSV file containing multiple rows of comma separated values example:- internalID,drivername, usreg,canadareg. I am basically using the CSV file to compare the values with the database table values. To compare the values to database values, I am adding a JDBC request with a query 'select internalID,drivername,usreg,canadareg from data where internalid ='${internalID'}' and providing the variables names to store the column data result. I use the groovy JSR233 and call the variables names in the script by declaring String a = vars.get("dintID_${counter}") where dintID is the variable name provided in the JDBC . The issue is when I run the script the first line of data in CSV files gets executed successfully, then the second line data in CSV file is passed to SQL statement correct, however the vars.get("dintid_${counter}") always stays at previous record meaning it does not go to next internalid(dintID). I have checked that my counter is incrementing. No idea how to resolve the issue. Does anyone know what mistake I am doing.
If you take a look at JSR223 Sampler documentation you will see that:
The JSR223 test elements have a feature (compilation) that can significantly increase performance. To benefit from this feature:
Use Script files instead of inlining them. This will make JMeter compile them if this feature is available on ScriptEngine and cache them.
Or Use Script Text and check Cache compiled script if available property.
When using this feature, ensure your script code does not use JMeter variables or JMeter function calls directly in script code as caching would only cache first replacement. Instead use script parameters.
So if the counter is a JMeter Variable - it will always be the initial value and it won't increment on subsequent iterations.
So you need to change the line to:
String a = vars.get('dintID_' + vars.get('counter'))
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It

How to pass cypress environment variable from cucumber feature file?

I want to pass cypress environment variables from cucumber feature file. But while running scripts in cypress runner getting 404 NOT FOUND error.
Any Ideas please?
Versions used:
"cypress": "^9.5.4",
"cypress-cucumber-preprocessor": "^4.3.1"
Below, I show you how to use any variable within a feature file. You only have to replace the variable in the example (which is assetName) by your environment variable.
Feature: Business critical scenarios
Verify the proper operation of most critial scearnios
Scenario Outline: Add a asset successfully
Given I go to the Add Asset tab
When Validate page title and url
And I type the valid name <assetName> in the asset input box
Then I press send button
And Validate the asset <assetName> is added successfully
Examples:
| assetName |
| "ABCD0000000026" |
Notes:
In my example the variable within the section Examples and below the field assetName, it's in quotes because the expected variable in my test file and linked with those steps, it's a string. If you are using int you must skip the quotes.
If you add more values below ABCD0000000026, your test will run as many times as values you add, like a loop

How to execute a script(say python or java etc) based on the value of the property in Apache NiFi

I have a flow file containing key value pairs, will read from Kafka and send to Nifi, using Getfile I will receive the file and then using Configure Process we can extract the contents of flowfile and keep them as flowfile attributes by adding matching regex.
Now after that I need to use specific attribute(s)(which I have got in the above step) and its value(s) and compare with the particular string value or will read the corresponding property value from nifi.properties file or custom properties file.
Now based on the validity I need to execute a script using ExecuteStream Command, suppose the extracted attribute value and nifi.properties or custom properties value matches then i should execute the script.
Here the query is how to compare the property values and execute the script.

Return a String from a Windows Batch file

I want to find the target branch when a pull request is submitted on GitHub, in my Jenkins pipeline. To achieve this I am doing the following:
I am invoking a windows batch file from my Jenkinsfile, which in turn invokes a nodejs script. This script internally invokes GitHub APIs to get the target branch which is to be set on some variable in Jenkinsfile(code snippet given below):
Jenkinsfile
env.TARGET_BRANCH = bat "GetTargetBranchFromGit.bat ${env.BRANCH_NAME}"
BatchFile:
node getTargetBranchForPR.js %1
But unfortunately, the variable env.TARGET_BRANCH is not getting set to the target branch even though the nodejs script gets the right value. I am in fact not able to return the value from the batch file. Could someone please help me here?
#npocmaka mention is the right way: How to do I get the output of a shell command executed using into a variable from Jenkinsfile (groovy)?
Accodring to Jenkins' documentation.
returnStdout (optional) If checked, standard output from the task is
returned as the step value as a String, rather than being printed to
the build log. (Standard error, if any, will still be printed to the
log.) You will often want to call .trim() on the result to strip off a
trailing newline.
So your code should look like
env.TARGET_BRANCH = bat( script: "GetTargetBranchFromGit.bat ${env.BRANCH_NAME}",
returnStdout: true
).trim()
If you get back more than expected you probably need to parse it.

getXmlHolder and context.expand - What does the arguments description mean

I am trying to insert values into the Request and Capture the response from the soapui pro Testsuite/testcase/testStep, using groovy script, without creating any property or assertions using soapui pro wizard. Everything i am trying to do using groovy script file in Soapui pro. But after 11 days of my self learning process I am forced to ask the in the forum:
I went thru almost 100 sites talking about how to capture request/response value.
But none explains the following:
getXmlHolder ("DeliverStatus#Request")
what does "deliveryStatus" & "Request" means and what does it contains. Which part of xml file is it. What does it signify
context.expand
For all my attempts i have got Null exception.
But i have been able to successfull script using groovy in the "Script tab in the Response section". But unable to do in using testsuite Groovy Script.
Please help.. Thanking all in advance
Regards
Am
DeliverStatus is basically meaningless - it is the name of your test step.
Request means that you look at the XML request that will be sent by SoapUI.
You can replace Request with Response and get the result of the API call.
context.expend allows you to get the value of the request or the response as well as specific XPaths within them. I'm not familiar with the getXmlHolder method - but it looks like it gets an XML string as input (can be a fragment) and turns it into an object you can work with.
My recommendation - if you are not using it already, is to right click on the Groovy editing area and choose Get Data --> Test Suite --> Test Case --> Test Step --> Response --> and navigate to the path in the response to which you want to access.
This will set the value of that XML fragment into a string variable of your choosing.
Afterwards you can use the getXmlHolder to convert that string into an object.
I also recommend using the XmlSlurper for parsing an XML string into an object.

Resources