I need to validate request time out in karate api testing - api

We ar doing api testing using karate and i want to provide less time out and validate 408 error
Tried * configure requestTimeout=100

Maybe this will work. If it doesn't you can assume this is not supported by Karate. In my experience, these kinds of tests are not worth automating. Also look at the option of using cURL directly: Using cURL for API automation in Karate
* configure readTimeout = 100
* url someUrl
* method get
* status 408

Related

Same HTTPS request works in Postman but gives 400 Bad Request in JMeter

I think I tried all the possible combinations of headers and body for my POST request in JMeter but is giving me 400 Bad Request saying that the languagePairID parameter from the body is invalid even tho it is exactly same as in Postman.
My headers:
And the request:
Meanwhile in Postman in works perfectly fine:
I tried checking and unchecking the multipart/form-data and browser-compatible headers, but nothing seems to help. I read that using Wireshark might be useful in such cases but I think for this one is not possible as it is HTTPS. I will be very grateful for any advice.
Uncheck "Use mutipart/form-data"
Remove everything from the "Body Data" tab
Switch to "Parameters" tab and put your parameters there:
Going forward be informed that you can easily convert your Postman script into JMeter:
Start JMeter's HTTP(S) Test Script Recorder
Import JMeter's certificate to Postman
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate relevant HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

JMeter testing for the url which contains # as path param

I have REST API which takes the username as a path parameter like this - app/users/{username}.
As per the business requirement, the username can be an email address as well.
Application is developed and we can test using postman, curl etc., by encoding the URL. But when we use JMeter to test the same API,
We are not able to send the encoded URL using JMeter. To demonstrate the problem, I created a webhook site(https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter)
and requested as below.
"GET https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter"
This resulted in a webhook as below
"https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter#jmeter"
But we want the output like below which we could accomplish by postman or curl.
curl --location --request GET 'https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter'
Please help how I need to prepare my JMeter script which produce the same output as above (in curl)
I cannot reproduce your issue using latest JMeter 5.4
Not sure what does your "webhook" do, however in a sniffer tool like Wireshark request paths are exactly the same for curl and JMeter and no %40 doesn't get decoded into #
If you're capable of sending your request successfully via curl or postman you should be able to record it using HTTP(S) Test Script Recorder - this way you will get appropriate JMeter configuration.

Bad Request : 400, when generating bearer token for OAuth2.0

I have setup an api in jmeter which will generate the bearer token for OAuth 2.0. When checking the request body in view result tree listener, seems like jmeter is not parsing the -Client Secret key.
request making
View Result tree - Request body
Response - 400
Please try the below,
Tried it on postman, (working fine)
Now from JMeter, (working fine)
I guess you missed the checkboxes (URL Encode?) in the request parameters in the Jmeter section
HTTP Status 400 means "bad request", one of your request parameters is not correct, like URL or request data or request headers, cross check them with browser/postman
If you're able to successfully execute the request using Postman you can just record the request from Postman using JMeter's HTTP(S) Test Script Recorder
Start JMeter proxy server
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate appropriate HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Karate API Tests - Post Request failing but works using Jmeter

I am trying to implement testing POST request for my APIs using KARATE, but getting 403 - expected csrf token not found.
However, I am able to perform POST Request using Jmeter - Login to the application, perform GET request and get the XSRF Token from GET request RESPONSE HEADERS and pass it in the POST request in Header Manager in Jmeter. That way, I am able to create a new resource using POST. I am not sure why this approach isn't working in Karate.
You must be missing some header. The fastest way you can solve this is by collaborating with someone on the server-side dev team.
Refer to this example in the Karate demos that uses CSRF:

How to stub an API when testing with Selenium Server

I'm using Nightwatch.js to test a MERN stack application—it makes calls to the Twilio API when it receives a POST request at /sms/outgoing/.
I would rather not send SMS messages every time I run my e2e tests—instead I'd like to stub out the behaviour and, ideally, return the request data, so that I can check my app is submitting the correct info.
I have looked at libraries such as nock and fetch-mock, but neither of these will work with tests that rely on selenium.
Is there a library that can intercept requests made by Selenium Server and provide the stubbing behaviour I'm after?
As you have mentioned nock and fetch-mock, I assume you're using a node server?
If that is the case, you could modify the server to detect an environment variable process.env.MOCK_API and return hard-coded responses to fetch request using fetch-reply-with