I am trying to use Chrome DevTools Protocol in conjunction with Cefsharp.
I found a description of Chrome DevTools Protocol:https://chromedevtools.github.io/devtools-protocol/
For example, I wanted to try to intercept/receive data from the server that
the server sends when loading a page using CEFsharp over the WebSocket protocol.
I found a function in the description - Network.webSocketFrameReceived:
https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-webSocketFrameReceived
If I understood correctly, I should use the Cefsharp function:https://cefsharp.github.io/api/94.4.x/html/M_CefSharp_IBrowserHost_SendDevToolsMessage.htm
bool SendDevToolsMessage(string messageAsJson);
But I can't figure out how to compose the "messageAsJson" message itself for the -Network.webSocketFrameReceived function.
The description says that the Network.webSocketFrameReceived function has three parameters:
requested (Request identifier)
Monotonic Time(Timestamp)
WebSocket Frame(WebSocket response data)
I don't understand how to use these three parameters.
Can someone please help with this?
How to compose a json message that would be a correct call to this function?
Related
I am writing UI automation script using karate DSL. In this at certain point I need to get value from network call in chrome. I want to interact with one of the webservice call in chrome devtools network tab and get the json response of that webservice.
I need this because I have to extract the value from that particular call and pass it on to the next step in my automation script.
I have seen the question related to sessionStorage(Is there a way of getting a sessionStorage using Karate DSL?) but I wonder how to do the same for network call using script command or any other way?
The first thing I would recommend is don't forget that Karate is an API testing tool at its core. Maybe all you need to do is manually make that call and get the response. You should be able to scrape the HTML and get the host and parameters needed.
That said - there's a new feature (only for Chrome) which is documented here: https://github.com/intuit/karate/tree/develop/karate-core#intercepting-http-requests - and is available in 0.9.6.RC2
It may not directly solve for what you want, but in a Karate mock, you should be able to set a value for use later e.g. by using a Java singleton or writing to a temp-file.
If there is something oddly more specific you need, please contribute code to Karate. Finally, there is an experimental way in which you can actually make raw requests to the Chrome DevTools session: https://github.com/intuit/karate/tree/develop/examples/ui-test#devtools-protocol-tips - it is for advanced users, but maybe you are one :)
Postwoman (now Hoppscotch) is an API request builder (like Postman) that I love the idea of because it's open source, but I'm not getting any response showing up in the Response field. It's a private API I'm hitting so I'd rather not show my request but it's a POST and my API is sending back the correct response (that works fine in Postman). I'm seeing the following error in the browser console:
TypeError: text.match is not a function
Is anybody else having this problem?
Adding browser extension:
https://addons.mozilla.org/en-US/firefox/addon/hoppscotch/
done the trick for me
We have IBM cloud function API which accepts filename as a parameter. If I give filename which includes + or non english characters(chinese,japanese, etc) the api is returning 404 with message:"Error: Whoops. Verb not supported."
Please can you help me on this.
"Error: Whoops. Verb not supported."
This response from APIConnect when you consume the API implies Invoke action is not happening, that means input parameters are not as per expectation.
The backend of API Connect of every action in Assembly section is developed on JS and XSLT. Mainly for INVOKE action, it uses the concept of OpenURL to invoke the backend REST service.
From my understanding, JS will accept non-English and "+" operators but it will be part of the string - what I mean is this will not concat two strings.
Please try to drag "Gateway" action to the policy and execute the command
console.error("Input Req ::"+apim.getvariable('request.verb'));
Please share the response what you get in the DataPower gateway for this invoke.
I am developing a Rest API and testing it with Behat and mink-selenium2-driver (for the first time) . For security purposes, every call needs to contain a apikey in the request header.
My Problem is, i cannot set the header. My test looks like this:
Given I add "X_ApiKey" header equal to "test"
When I send a GET request to "/notice"
Then the response status code should be 200
But I keep getting a 403.
Any solutions?
In selenium it is imposible.
Need to test this on other driver, like guzzle
To my knowledge, selenium driver lead chrome, but not how it is working. Proposition to check of use others drivers like guzzle, where you can set headers is a answer, in my opinion.
No i found you could additionally other option. It's recommended you use a proxy to inject additional headers to the requests generated by the browser.
To do this i found
* http://wiremock.org/
You should use the behatch package which includes a behatch/rest context.
However, the selenium driver should only be used when you specifically need a browser, for javascript for example. In this case, as you are testing a API endpoint, using a browser will only slow you down and not bring any benefit.
It's possible to use Restler, a micro framework which can help with RESTful API testing in Behat. It support behavior Driven API testing using Behat and Guzzle.
Here is the example:
Given that "X_ApiKey" header is set to "test"
When I request "/notice"
Then the response status code should be 200
Here is another example from negotiation-format.feature file:
Scenario: One with more `q` should be selected, q = 1 when not defined
Given that "Accept" header is set to "application/json;q=0.8,application/xml"
When I request "/examples/_003_multiformat/bmi"
Then the response status code should be 200
And the response is XML
And the type is "array"
I'm using RESTlet to handle PUT requests from a browser and after a successful PUT, I want to redirect the browser to different web page.
Seems like a standard PUT->REDIRECT->GET to me, but I'm not figuring out how to do it in my RESTlet resource.
Here is my code after the PUT has done the requested work:
getResponse().redirectSeeOther("/account");
However that results in the browser getting:
Response Headers
Location riap://application/account
Of course, "riap" protocol is meaningless to the browser and "application" is not a server name. It seems like there ought to be a way to send a redirect back to the browser without building the entire URL in my redirectSeeOther() call. Building the URL seems like to could be error prone.
Is there an easy way to redirect without building the whole URL from the ground up?
Thanks!
Sincerely,
Stephen McCants
Although I am not 100% sure in what type of class you are trying to do this.
Try :
Reference reference = getRequest().getRootRef().clone().addSegment("account");
redirectSeeOther(reference);
I usually also then set the body as
return new ReferenceList(Arrays.asList(reference)).getTextRepresentation();
but that may not be necessary for all clients, or at all. I will usually use this style in a class that extends ServerResource - Restlet (2.0.x or 2.1.x).