webdriverio-community / wdio-intercept-service

🕸 Capture and assert HTTP ajax calls in webdriver.io
MIT License
104 stars 33 forks source link

Issue with Intercepting Requests: Unwanted Logs for Excluded URLs #861

Closed ASaiAnudeep closed 3 weeks ago

ASaiAnudeep commented 3 weeks ago

I am encountering an issue where unwanted logs appear in the console while intercepting network requests. Specifically, I am seeing repeated log entries like the following:

POST request to https://www.google-analytics.com ... had no response headers!

I have tried to exclude these URLs from interception by using the excludeUrls method, but the logs still persist. Here is the code snippet I used for exclusion:

await browser.setupInterceptor();
await browser.excludeUrls([
  /.*google-analytics.*/,
  /.*facebook.*/,
]);

If there is a known issue or workaround, please let me know.

christian-bromann commented 3 weeks ago

@ASaiAnudeep thanks for raising the issue. We will soon deprecate this service as WebdriverIO supports its own network mocking capabilities in which you can implement the given code as following:

const mocks = await Promise.all([
  browser.mock('.*google-analytics.*'),
  browser.mock('.*facebook.*')
])
mocks.forEach((mock) => mock.abort())

We recommend update to latest WebdriverIO and give this a try.

ASaiAnudeep commented 3 weeks ago

Thanks a lot for the quick response @christian-bromann , I will give it a try.

ASaiAnudeep commented 3 weeks ago

I wanted to mention that using browser.mock is not feasible for us because it isn't supported on BrowserStack or SauceLabs, which are critical to our testing infrastructure. This limitation is a hard blocker for our testing setup.

Is there any alternative approach or workaround that you could suggest for handling it.

Thanks in advance.

christian-bromann commented 3 weeks ago

@ASaiAnudeep in v9 the mock command uses WebDriver Bidi primitives which should work on Sauce Labs and BrowserStack. I will update the docs to reflect that.