Skip to content
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

Other request types not being collected #640

Open
ctm-adamstribblehill opened this issue Aug 24, 2023 · 7 comments
Open

Other request types not being collected #640

ctm-adamstribblehill opened this issue Aug 24, 2023 · 7 comments
Labels

Comments

@ctm-adamstribblehill
Copy link

ctm-adamstribblehill commented Aug 24, 2023

Hi

I am using WebDriverIO to perform end to end testing of customer journeys, at certain points our tag management system initiates network requests to endpoints such as Google Analytics 4, Floodlights, Facebook, etc.

We would like to be able to test / check the requests emitted contain the correct data however when calling await browser.getRequests() they are not returned. I believe this is because they are not fetch or XHR request types, is this correct?

And if this is correct is there expected to be any future releases to allow such monitoring / capture to occur.

Below is an example of a request being sent that WebDriverIO is not picking up.
image

@bardisg
Copy link

bardisg commented Aug 29, 2023

I have a similar requirement.
To be able to intercept the requests that are generated by beacon calls (navigator.sendBeacon() method) that are of type "ping".

I assume that https://github.com/webdriverio-community/wdio-intercept-service/blob/main/lib/interceptor.js needs to have a replaceSendBeacon implementation likewise fetch and Xhr ones.

Cypress is already supporting it so I was wondering if there is any plan to add support in the near future.

@tehhowch
Copy link
Contributor

I have a similar requirement. To be able to intercept the requests that are generated by beacon calls (navigator.sendBeacon() method) that are of type "ping".

I assume that https://github.com/webdriverio-community/wdio-intercept-service/blob/main/lib/interceptor.js needs to have a replaceSendBeacon implementation likewise fetch and Xhr ones.

Cypress is already supporting it so I was wondering if there is any plan to add support in the near future.

Indeed, we would need an IE-parsable (does not have to support IE, just be parsed by it) implementation of such. A PR contributing (& testing!) that functionality would be appreciated.

@tehhowch
Copy link
Contributor

@ctm-adamstribblehill I would need to see the code that triggers the request, not the request details. For example, if the initiating code uses a private reference to fetch or XMLHttpRequest and does not look it up from the window, this library is not able to intercept the request.

@ctm-adamstribblehill
Copy link
Author

@tehhowch This request is not directly initiated / triggered by any code that we develop.

We have a tag management system (Tealium IQ), we configure Tealium to activate the Facebook Pixel tag deployed to the page via Tealium when the appropriate conditions are met and a Tealium event is emitted. This then results in the Facebook network request to be transmitted as attached above.

I have been able to collect other network requests emitted via Tealium such as a Yahoo Dot request but this is an XHR request.

image

image

@tehhowch
Copy link
Contributor

tehhowch commented Sep 5, 2023

@ctm-adamstribblehill reading more closely this time, I see you are basically asking about intercepting requests made by the browser itself for e.g. the src attribute of an <image> tag. That is not currently possible with this WDIO library, because those requests do not use the fetch or XMLHttpRequest objects. See #79 for an existing issue like this.

I do not expect support to be added for non-JS requests, either, since it would (AFAICT) require protocol-level interception and this library provides functionality in all modern browsers, not just those that extend Chromium.

You will probably need to switch to some other interception library that offers tie-ins with the chrome dev tools / puppeteer.

(I welcome any corrections to my assumptions above!)

@bardisg
Copy link

bardisg commented Sep 7, 2023

Hello @tehhowch,

I have raised a PR to add support for intercepting queued beacon requests at #651

Would love to assist and get this in the next release. For the time being I unblocked myself using patch-package with the same changes.

On a sidenote, the prettier pre-push check fails with existing code from main you might want to auto format the code base once at some point.

Thanks for the great package!

@rfariasesw
Copy link

hey guys, we're seeing the same issue and are unable to retrieve analytics request of type 'ping'.
any news of when will this be supported?

btw thanks for the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants