-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intercept Network calls #98
Comments
It's possible right now. However it'll require some digging into CRI's docs. To understand this better, intercepting requests to provide test data? Maybe add an easier API something like
and for finer control
|
Yeah, we can mock any api call with test data. |
WIP Example1:
Example2:
Example3:
|
A small change here would be useful,
This gives the user ability to intercept the request, process any data it may contain and return a mock response dynamically. |
For first pass we must make this very simple If we approach this from a testing perspective Case 1: Mock the requested url with a test data url
Case 2: Return JSON
Case 3: Return the result of a function
|
@zabil i like the First approach 👍 Can i know which approach has the team decided to go with ? |
@zabil if we match only using url user may not have flexibility to identify any request with specific method, header, or post-data. can it be like eg: |
Because the application implements the request For headers they can be read/modified from
|
We will be following below design for intercepting APIs case 1: block url => |
Regex to match URLs will be handle in #142 |
Fix should be available in 7e4fdc3. Below is an example script for all 5 cases mentioned in the issue. Steps to run the sample script,
#code.js
|
Getting |
Have missed |
Hi @NivedhaSenthil , If I want to add a new key to the postData is this the best way to do it ?
Is there another way to do this ? Thanks, |
@vitor-gyant have you tried
|
* Added type test from specs for openBrowser, closeBrowser The commit adds some tests for the functions openBrowser and closeBrowser. The tests are based on the examples provided in the official documentation. Signed-off-by: Filippo Maria Panelli <filippo.panelli@gmail.com> * Added type test for switchTo and fixed switchTo type def This commit adds tests for switchTo type definition. The tests are derived from the examples in the official documentation. Adding those tests shows that the type definition was not correct. This commit fixes the types of the arguments of switchTo function. Signed-off-by: Filippo Maria Panelli <filippo.panelli@gmail.com> * Added type test for intercept and fixed type def This commit adds tests for intercept type definition. The tests are derived from the examples in the official documentation and from Nivedha's comment here #98 (comment). Adding those tests shows that the type definition was not correct. This commit fixes the types of the arguments of intercept function. Signed-off-by: Filippo Maria Panelli <filippo.panelli@gmail.com> * Added type tests for emulateNetwork, emulateDevice, setViewport Signed-off-by: Filippo Maria Panelli <filippo.panelli@gmail.com> * Added type test for openTab and fixed type def This commit adds tests for openTab type definition. The tests are derived from the examples in the official documentation. Adding those tests shows that the type definition was not correct. This commit fixes the types of the arguments of openTab function. Signed-off-by: Filippo Maria Panelli <filippo.panelli@gmail.com> * Added type test for closeTab and fixed type def This commit adds tests for closeTab type definition. The tests are derived from the examples in the official documentation. Adding those tests shows that the type definition was not correct. This commit fixes the types of the arguments of openTab function. Signed-off-by: Filippo Maria Panelli <filippo.panelli@gmail.com> * Added type test for several taiko functions This commit adds tests for type definitions for: - openIncognitoWindow - closeIncognitoWindow - overridePermissions, - clearPermissionOverrides The tests are derived from the examples in the official documentation. Signed-off-by: Filippo Maria Panelli <filippo.panelli@gmail.com> * Added type tests for the remaining browser actions This commit adds tests for type definitions for: - setCookie - deleteCookies - getCookies - setLocation - clearIntercept The tests are derived from the examples in the official documentation. This commit also introduces the concept of getting some types from the official devtools-protocol repository. Signed-off-by: Filippo Maria Panelli <filippo.panelli@gmail.com> Co-authored-by: Nivedha <nivedhasenthil@gmail.com>
I'm testing the intercept functionality with the form at https://tryphp.w3schools.com/showphp.php?filename=demo_form_post while intercepting https://tryphp.w3schools.com/demo/welcome.php using:
I'm able to modify the parameters in request.request.postData but request.continue() is not taking effect - the data shown at https://tryphp.w3schools.com/showphp.php?filename=demo_form_post after sending the form is the one written in the textBox instead of "This comes from Taiko" Am I missing something? Thank you |
yes, I could see it is broken. Taking a look at it, thanks for reporting |
Thanks @NivedhaSenthil. Please, let me know if I should open a new issue for this behavior |
@rmallof yes, that will be good. |
Done: #1520 Thanks @zabil @NivedhaSenthil ! |
Does it work with headless:true? |
Yes it should work in both headless and headful mode |
@zabil - In puppeteer, we can intercept API calls, continue or abort network request/response.
Can this be implemented in taiko ?
Code in puppeteer
The text was updated successfully, but these errors were encountered: