Block specific AJAX requests with browser or OS - ajax

I'm trying to test a product to make sure it fails correctly and therefore want to be able to block a specific AJAX request from returning any data. I could modify the source to make the request fail but I have to prove it works without changing the code.
How could I go about blocking a specific url from returning data?

This might help - its a fire fox plugin - have not tried it but it looks good - it says it allows you to edit and alter requests- addons.mozilla.org/en-US/firefox/addon/tamper-data

Related

Why is my HTTP request URL not being generated for a Logic App?

Good morning. I am new to logic apps and I am trying to figure out how I can trigger the execution based on a GET URL with three parameters. All the examples I've found on Google show the URL being generated once the JSON and relative path is entered, but that's not happening for me. Perhaps it's because I am creating the logic app in VS.
Here's what my "When a HTTP request is received" step looks like in the logic app.
I also tried removing the JSON and just using the parameters to pass the values to the function, as shown below. I'm just not sure the best way to do this.
All I really need to do is get the three parameters into the logic app so I can perform a function call with the parameters. Any suggestions would be greatly appreciated!
Why is my HTTP request URL not being generated for a Logic App?
You need to click save, and then the url will be automatically generated for the When a HTTP request is received trigger:
You can use this expression to accept values through GET parameters:
triggerOutputs()['queries']['parameter-name']
For example:
Noteļ¼š
Queries need to pass parameters in the form of json.

Rerun Postman Test without re-submiting the API Request

Is it possible to rerun the tests created in the post response test without
resubmitting the request?
For example you submit an API request in Postman, then it comes back with
some data.
I want to just re-run the scripts against this data.
Could be really useful in debugging these post-response scripts.
I want to rerun Tests in area 1 without hitting the Send button
(area 2). That way I can test the javascript correctness of my Test scripts without having to wait for server responses.
You can use https://postman-echo.com/post and their API will echo the request you send. So basically you create the actual request once and then use the result in the ECHO call to do the development.
More info here:
https://docs.postman-echo.com/?version=latest
I'm afraid there is no better way at the moment.
I was looking for the same thing and came across this tip on the PostMan Community.
https://community.postman.com/t/re-run-test-script-without-re-sending-request/9160/8
Basically you:
Make your request
Save your response as an example
Create a PostMan mock from that response
Rerun and build up your test against the mock (and any variants, like failure cases)
Run against the original and verify everything is good.
While this workaround helps get the job done, I do wish that they could just make it so that you could hold the original state of the response and the env, run your tests, reset to the original state, rerun your tests and tweak until it all works.
You can write test entire test or the part you want to execute twice in a function and call that function 2 times, that the easy and low effort and maintenance way I am looking

is there are way to ignore page load when running seleniume cucumber

Hi is there any way to ignore the page load when running selenium cucumber, because it always fail my test and i just want to check if that content is present or not.
please don't say add sleep.
the issue im having is that the content is present but its always waiting the page to be fully loaded and sometimes it got stock trying to get some api call to a 3rd party company.
Here are some approaches you could try
Change your driver and us webkit. Setup webkit to not load external links. See http://robots.thoughtbot.com/speed-up-javascript-capybara-specs-by-blacklisting-urls
Ensure you understand and us the has_no methods if you are testing that something is not present e.g. use
expect(page).to have_no_css '.test' # fast
rather than
expect(page).to !have_css('.test') # slow will always wait until timeout
Change the default timeout to something shorter (perhaps only for this scenario, using a tag)

ProtocolViolationException Load testing web service (GET action with content-body)

I created an ASP.NET MVC4 Web API service (REST) with a single GET action. The action currently needs 11 input values, so rather than passing all of those values in the URL, I opted to encapsulate those values into a single class type and have it passed as Content-Body. When I test in Fiddler, I specify the verb as GET, and enter the JSON text in the "Request Body" input box. This works great!
The problem is when I attempt to perform Load Testing in Visual Studio 2010 Ultimate. I am able to specify the GET action and the JSON Content-Body just fine. But when I run the Load test, VS reports exceptions of type ProtocolViolationException (Cannot send a content-body with this verb-type) in the test results. The test executes in 1ms so I suspect the exceptions are causing the test to immediately abort. What can I do to avoid those exceptions? I'd prefer to not change my API to use URL arguments just to work-around the test tooling. If I should change the API for other reasons, let me know. Thanks!
I found it easier to put this answer rather than carry on the discussions.
Sending content with GET is not defined in RFC 2616 yet it has not been prohibited. So as far as the spec is concerned we are in a territory that we have to make our judgement.
GET is canonically used to get a resource. So you are retrieving this resource using this verb with the parameters you are sending. Since GET is both safe and idempotent, it is ideal for caching. Caching usually takes place based on the resource URI - and sometimes based on various headers. The point is cache implementations - AFAIK - would not use the GET content (and to be honest I have not seen any GET with content in real world). And it would not make sense to include the content in the key generation since it reduces the scalability of the caches.
If you have parameters to send, they must be in the URI since this is part of what defines that URI. As such, I strongly believe sending content with GET is wrong.
Even when you look at implementations such as OData, they put the criteria in the URI. I cannot imagine your (or any) applications requirements is beyond OData query requirements.

Call a controller's method from an external ruby script

I'm creating an external service of my rails app. This is always listening a rabbitmq queue and all their messages should be redirected to some methods of the rails controllers.
I've tried these approaches:
AMQP subscriber inside Rails app
What's the correct way to run one controller action from another controller action without an HTTP redirect?
http://www.misuse.org/science/2007/07/24/firing-rails-controller-actions-from-command-line-console/
The first one allowed me only to access the model (Anyway I suppose must be the base for what I want). The second one... never worked for me. And the last one doesn't works on rails 3 ( ActionController::Integration doesn't exists)
I think that the last approach still could be used if I figure out how the sessions are handled in rails 3. In any case, somebody had tried something similar before? Any suggestion will be appreciated.
Why not just send the request via an HTTP request? Your controller basically makes actions visible via URLs - simply making a request to the URL is essentially the same as calling the controller code, and it keeps your code working like a software service/API. You could even just use curl to do this if you want.
Otherwise, if the two files are in the same machine/folder, you could try to explicitly include the one controller code in the other, but that seems like maybe not the way to go. Depends on how you want the end result to work.

Resources