Page Load Errors using webdriverio

17 Views Asked by At

Is there a way I can test pageLoad errors in webdriverIo.

I am currently running UI automation using webdriver io. And I want to capture pageLoad errors i.e. network call errors e.g. a page fails to load due to an API error. How do I capture that in my automation.

I have tried the following capabilities:

const chromeOptions = {
    capabilities: {
        browserName: "chrome"
    },
    services: ["intercept"]
}

I have the following dependencies:

  • "webdriverio": "8.10.4",
  • "wdio-intercept-service": "^4.4.0"

I am importing:

import WebdriverAjax from "wdio-intercept-service"

We have the following code piece-

            await browser.url(url)
            browser.setupInterceptor()
            const request = browser.getRequest(0)

But i keep getting the error:

2024-03-22T16:40:35.596Z [ERROR] browser.setupInterceptor is not a function
2024-03-22T16:40:36.248Z [ERROR] browser.setupInterceptor is not a function
2024-03-22T16:40:37.051Z [ERROR] browser.setupInterceptor is not a function

Is there a another way I can get this to work? or am I missing something here?

I have followed the following documentations - https://github.com/webdriverio-community/wdio-intercept-service/blob/main/README.md

0

There are 0 best solutions below