Comments (6)
A better check would be to have setupInterceptor
only do the replaces if its own flag has not been set - it's possible for page code to do its own polyfills / middleware.
The issue you are experiencing is not due to the library itself - otherwise our unit tests with multiple requests would be failing.
from wdio-intercept-service.
Thanks for answering. I pushed an example here: https://github.com/muhserks/wdio-intercept-service/tree/reproduce-776
In my WDIO framework, I am only waiting that a request was completed after a click. I call always setupInterceptor and waitUntil browser.hasPendingRequests() is false. But when 2nd request is done, browser.hasPendingRequests() is always true.
The weird thing is, this works with wdio intercept V4.2.0.
Anyway, Let me see if I can figure out a way to avoid the replacement in setupInterceptor.
from wdio-intercept-service.
Why do you repeatedly call setupInterceptor
, when the interceptor is already loaded?
from wdio-intercept-service.
Well, simplest example is clearing all the requests. Referring to #249 (comment) it was the suggested way and it makes sense.
But my case is that in the application, same page, when you select certain things, ajax requests are made for each click/select/whatever. If I don't wait for it to be finished, subsequent actions will fail. There is no DOM selection possibility to do it in any other way.
Bottom line is, I have this in my framework (setupInterceptor and waitUntil browser.hasPendingRequests() is false) for a couple of methods which are getting called throughout the tests. I do not set up the interceptor for each test seperately, it is just setup when it is used (and hopefully disabled afterwards when I can finally update ....).
Putting the interceptor stuff directly into the tests is no option. Keeping track on my side if it is already setup or not is also not ideal imo.
from wdio-intercept-service.
I don't think I had thought through the ramifications of calling setupInterceptor
multiple times when I made that post, unfortunately.
If you're embedding this in your framework rather than the tests that need it, I suggest ensuring it's done after your framework has executed browser.url
rather than as a part of clicks. You could also abuse some private implementation details of this service and use browser.execute
to set window.__webdriverajax.requests = [];
e.g. as your own clearSpiedRequests
method.
(That the application you're testing both requires the network to settle before you can do the next thing, and provides no UI feedback as to when the network has settled, seems like terrible UX and something you should raise with your developer team.)
Providing public API to clear the captured requests is certainly a reasonable request, btw.
from wdio-intercept-service.
If you navigate through your application and change pages, you need to setup the interceptor again and I do not want to do that for each link I may click. I only execute browser.url once to get to the login screen. It is also not the case that I always need the interceptor on that page with ajax requests.
Even though I implemented disable interceptor (shame on me), enabling it is missing. Calling setupInterceptor to enable it again will not work as we already figured out (at least if you stay on the same page).
Clearing the requests is not only window.__webdriverajax.requests = [];
. The session store needs also to be cleared. Otherwise you will get weird results and you could also hit the limit again.
I did an implementation now on my side via browser execute
to take care of all 3 cases.
For me, these changes do make sense and it could also avoid surprises for other people using the interceptor. But that is just my opinion.
If you are cool with these changes, I can create a PR and we could continue from there. It is up to you.
With that being said, I am still a bit confused about window.__webdriverajax.requests
VS the requests in sessionstorage and how they are used. getRequests()
will use sessionstorage (if available), but hasPendingRequests will not rely on session storage. window.__webdriverajax.requests
can differ from sessionstorage after a page change, but gets cleared while calling the needed setup again. It will also differ if URLs are excluded, because URLs are only excluded while pushing into session storage
So why is the sessionstorage even needed? I am probably missing here something, but wouldn't it be sufficient to just use the namespace?
Oh, and thanks for the feedback.
from wdio-intercept-service.
Related Issues (20)
- (Version 4.2.2) Occasionally getting a java heap space error when running the network intercept too often HOT 1
- [Version 4.2.2] browser.disableInterceptor() is not a function HOT 1
- browser.getRequests() hanging without @wdio/sync module HOT 15
- Best practices with the wdio intercept service HOT 2
- Interceptor results are inconsistent
- Is there a way to abort the request? HOT 4
- Exception in .getRequests HOT 3
- Getting pending requests too HOT 1
- Intercepting segmentio messages HOT 5
- Not able to capture some api's called on Submit action HOT 4
- Cannot read property 'addCommand' of undefined HOT 11
- No request(empty array) returned from intercept service HOT 10
- Does getRequests() capture all the 'GET' calls in the network log? HOT 2
- can we have support async/await for wdio-intercept-service HOT 7
- wdio-intercept-service is not capturing requests invoked in iframe HOT 6
- Cypress does not intercept graphql query HOT 2
- Other request types not being collected HOT 7
- Getting [wdio-intercept-service]: the "index" property must be a non-negative integer error while trying to capture GET request HOT 1
- Why i can't intercept any request in my app?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wdio-intercept-service.