-
Notifications
You must be signed in to change notification settings - Fork 32
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
Intercepting XMLHttpRequests is broken #776
Comments
A better check would be to have The issue you are experiencing is not due to the library itself - otherwise our unit tests with multiple requests would be failing. |
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. Anyway, Let me see if I can figure out a way to avoid the replacement in setupInterceptor. |
Why do you repeatedly call |
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. 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. |
I don't think I had thought through the ramifications of calling 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 (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. |
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. I did an implementation now on my side via 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. With that being said, I am still a bit confused about Oh, and thanks for the feedback. |
Intercept Version : 4.4.0
WDIO Version: 8.32.3
I do not fully understand why it is failing, but when intercepting XMLHttpRequests, they will be duplicated inside the session storage.
Each intercepted request will create additional ones inside the array in session storage. Means, the 3rd request will create 3 entries, the 4th will create 4 entries ... and so on ... All have same URL, method etc ...
Looking at the stacktrace inside XMLHttpRequest.prototype.send shows that it somehow got replaced multiple times. Each send will call an additional send.
The only thing I found to fix this is to check at the beginning of replaceXHR (
wdio-intercept-service/lib/interceptor.js
Line 118 in b2df722
But still, I am a bit clueless here if that would be the fix here. @tehhowch Would you mind to share some wisdom here?
I will try to prepare something reproducable ...
The text was updated successfully, but these errors were encountered: