JMeter: Why JMeter ignores "&" from CSV? - multithreading

I have created a script in JMeter where it fetches Login credentials from CSV.
UserName: pshah
Password: Welcome&1
When I execute the script, I can see value in POST as:
UserName: pshah
But Password: Welcome
I would like to know why "&" is ignored from CSV.

In Http Request element, in parameters table check the encode checkbox as & is a reserved character in HTTP request.
Note you can debug by using a DebugSampler and replace name by ${UserName},${Password} where UserName and Password are your variable names. Use a View Results Tree to see if the issue is in loading the CSV or somewhere else
It appears there's a bug in the HTTP Renderer of the Request. As & is a separator of HTTP Request, it appears JMeter decodes the encoded value "Welcome%261" before showing parameters, this leads to presence of 1 parameter:
While the RAW one is OK:
So it's just a Display issue in HTTP renderer , you can ignore it as RAW shows the correct request is sent.
I opened bug:
https://bz.apache.org/bugzilla/show_bug.cgi?id=58413

For some reason, the 1 in the password Welcome&1 is showing up in the parameter name in the View result tree.
Check the values of userName and Password in the raw tab of View Result Tree in Jmeter ,which correctly shows Welcome&1
Check the response of your request, If it is successful then the username and password are passed correctly.

Related

How to extract username from Http QueryString in logic app?

I am sending query String as:
https://prod-17.westindia.logic.azure.com:443/workflows/f3b63b086e61420e8d76b7478f4b3e39/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=nESqZWY2NyAKKhCkaM0VnfenHuTqi1NSBjJdl9M5jNA&UserName=SecretName&Password=Nikita#123
I want to extract UserName in logic app. For that I have used Compose connector and use following statement in expression.
coalesce(triggerOutputs()['queries']?['UserName'] , 'blank')
I have tried this to:: triggerOutputs()['queries']?['UserName']
But I am getting one single blank space appended in front of UserName in output. Due to which, my condition is becoming false even if UserName is correct.
How to remove this extra space which is unnecessary appending to front.
HTTP Connector Output as :
In this scenario , password is working fine. As below is output:
You should use the trigger output and you should not use the Coalesce expression.

How to get and submit characters like letters with accents and 'ñ' in a Loopback 4 API

I have an API created in Loopback 4 which retrieves data from a database in PostgreSQL 13 encoded with UTF8. Visiting the API explorer (localhost:3000/explorer) and executing the GET requests I realize that even when the database fields contain characters like letters with accents and ñ's; the retrieved JSON only shows blanks in the position where the character must have appeared. For example, if the database has a field with a word like 'piña', the JSON returns 'pi a'.
When I try a POST request, inserting a field like 'ramírez' (note the í), in the database, the field is shown as 'ramφrez' and when I execute a GET of that entry, the JSON now has de correct value, 'ramírez'.
How can I fix that?
I'd recommend using the Buffer class:
var encodedString = Buffer.from('string', 'utf-8');
with this way you will be able to return anything you want. In NodeJS Buffer class already included so you don't need to install any dependencies.
If you don't get what you need you can change 'utf-8' part.

How to display actual value of a property which is using property expansion

I require some help on being able to get around displaying an endpoint from a SOAP Request.
Below I have a piece of code which retrieves an endpoint from a SOAP Request named 'TestAvailability' and outputs it to a file (the code is within a groovy script step).
def endpoint = testRunner.testCase.getTestStepByName('TestStep').get
Now here is the catch, in the file it outputs the endpoint as so:
ENDPOINT: ${#Project#BASE_URL}this_is_the_endpoint
The reason it displays ${#Project#BASE_URL} is because this is a variable set at project level so that the user can select their relevant environment from a drop down menu and that value will be displayed for the variable: ${#Project#BASE_URL}
But I don't want the project variable to be displayed but instead its value like so if ${#Project#BASE_URL} is set to 'testenv'
ENDPOINT: testenv_this_is_the_endpoint
My question is how do I change the code in order to display the endpoint correctly when outputted to a file?
You have a trivial issue. Since it is using property expansion in the endpoint, it request to expand it.
All you need is to change below statement
From:
testResult.append "\n\nENDPOINT: " +endpoint
To:
testResult.append "\n\nENDPOINT: ${context.expand(endpoint)}"

How to verify if values are updated or not by API using groovy in soap ui

I am using soapui and groovy for api automation and assertion.
Have one API which updates user profile data. i.e update username,firstname,lastname etc.
What is best way to verify that if data is updated or not after run update api. In groovy is there any way by which I can store previous data from API response then run update api and again check response and finally compare previous response and latest one?
What I have tried it comparing values which I am going to sent via API and values which API returns. If both equal then assume that values update. But this seems not perfect way to check update function.
Define a test case level custom property, say DEPARTMENT_NAME and value as needed.
Add a Script Assertion for the same request test step with below script:
//Check if the response is received
assert context.response, 'Response is null or empty'
//Parse text to json
def json = new groovy.json.JsonSlurper().parseText(context.response)
log.info "Department name from response ${json.data.name}"
assert json.data.name == context.expand('${#TestCase#DEPARTMENT_NAME}'), 'Department name is not matched'
You may also edit the request, and add the value as ${#TestCase#DEPARTMENT_NAME} instead of current fixed value XAPIAS Department. So that you can just change the value of department name at test case level property, the same is sent in the request and the same is verified in the response.
Use JDBC teststep to run query directly into database:
Use Xpath assertion to Validate your Update API
Assertion 1
/Results/ResultSet[1]/Row[1]/FirstName
Expected result
Updated FirstName
Assertion 2
/Results/ResultSet[1]/Row[1]/LastName
Updated Last Name
In our project we do it in this way:
First we execute all the APIs.
Then we Validate all the new/updated data in database in DB Validation testcase.
Works well in highly integrated environment as well.

Swagger API "required" - how much is this required?

I've created a Swagger (on nodejs/express) test API with this specification (only relevant part):
...
parameters:
- name: name
in: query
required: true
type: string
...
But I can call the url with empty paramter, for example
http://localhost/test?name=
And it works without any problem, throws no exception or any other sign. Why?
If I make a similar call from the terminal via curl or via postman, it works as well. I parsed the query from the request object and found that in this case, the query parameter is interpreted as an empty string.
Making the call via SwaggerUI is different though, as the UI will actually not make the call UNLESS the query field has a value.
Try doing console.log(req.query); in your handler. You will probably see {name: ''}. Which is legitimate, just that the value of name is an empty string.
Look at JSON4 here: Representing null in JSON. So name IS defined, but it's empty.
You will probably need to do a check for empty string values.
I hope this helps!

Resources