webdriverio: [π Bug]: Devtools Service - getMetrics fail - Unable to Identify the Main Resource
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
latest
Node.js Version
14
Mode
WDIO Testrunner
Which capabilities are you using?
{
browserName: 'chrome'
}
What happened?
I just copied the code from the documentation -> [https://webdriver.io/docs/devtools-service/#performance-testing]
With Node 18 -> it didnβt work (browser.enablePerformanceAudits is not a function)
So I switched to node 14 -> It works better but I have an issue as soon as I call getMetrics: Unable to identify the main resource
The Others devtools work correctly
What is your expected behavior?
It Should return the page metrics as expected
How to reproduce the bug.
Specs in ts:
describe('test perf', () => {
before(() => {
browser.enablePerformanceAudits()
})
it('should get the metrics', async () => {
await browser.url('https://www.google.fr')
await browser.getMetrics()
})
after(() => {
browser.disablePerformanceAudits()
})
})
No need to create other file but the conf to launch it
Relevant log output
npx wdio run ./wdio.conf.ts --suite test
Execution of 1 workers started at 2023-01-10T08:48:16.620Z
2023-01-10T08:48:16.637Z DEBUG @wdio/utils:initialiseServices: initialise service "chromedriver" as NPM package
2023-01-10T08:48:16.669Z DEBUG @wdio/utils:initialiseServices: initialise service "devtools" as NPM package
2023-01-10T08:48:17.241Z INFO chromedriver: Initiate Chromedriver Launcher (v8.0.1)
2023-01-10T08:48:17.241Z INFO @wdio/cli:launcher: Run onPrepare hook
2023-01-10T08:48:17.244Z INFO chromedriver: Start Chromedriver (/Users/e.frelon/quality/greentoolV2/node_modules/chromedriver/lib/chromedriver/chromedriver) with args --port=9515 --url-base=/
2023-01-10T08:48:17.262Z INFO chromedriver: Starting ChromeDriver 108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016}) on port 9515
2023-01-10T08:48:17.263Z INFO chromedriver: Only local connections are allowed.
2023-01-10T08:48:17.263Z INFO chromedriver: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
2023-01-10T08:48:17.263Z INFO chromedriver: ChromeDriver was started successfully.
2023-01-10T08:48:17.357Z DEBUG @wdio/cli:utils: Finished to run "onPrepare" hook in 115ms
2023-01-10T08:48:17.359Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2023-01-10T08:48:17.359Z DEBUG @wdio/cli:utils: Finished to run "onWorkerStart" hook in 0ms
2023-01-10T08:48:17.360Z INFO @wdio/local-runner: Start worker 0-0 with arg: run,./wdio.conf.ts,--suite,test
2023-01-10T08:48:17.364Z DEBUG @wdio/local-runner: Send command run to worker with cid "0-0"
[0-0] 2023-01-10T08:48:18.547Z INFO @wdio/local-runner: Run worker command: run
[0-0] 2023-01-10T08:48:18.615Z DEBUG @wdio/runner: init remote session
[0-0] 2023-01-10T08:48:18.620Z DEBUG @wdio/utils:initialiseServices: initialise service "chromedriver" as NPM package
[0-0] 2023-01-10T08:48:18.659Z DEBUG @wdio/utils:initialiseServices: initialise service "devtools" as NPM package
[0-0] 2023-01-10T08:48:19.075Z DEBUG @wdio/utils:shim: Finished to run "beforeSession" hook in 0ms
[0-0] RUNNING in chrome - file:///test/specs/example.e2e.ts
[0-0] 2023-01-10T08:48:19.167Z DEBUG @wdio/runner: init remote session
[0-0] 2023-01-10T08:48:19.169Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2023-01-10T08:48:19.273Z INFO webdriver: [POST] http://localhost:9515/session
[0-0] 2023-01-10T08:48:19.273Z INFO webdriver: DATA {
[0-0] capabilities: {
[0-0] alwaysMatch: { browserName: 'chrome', acceptInsecureCerts: true },
[0-0] firstMatch: [ {} ]
[0-0] },
[0-0] desiredCapabilities: { browserName: 'chrome', acceptInsecureCerts: true }
[0-0] }
[0-0] 2023-01-10T08:48:21.076Z DEBUG @wdio/utils:shim: Finished to run "beforeCommand" hook in 0ms
[0-0] 2023-01-10T08:48:21.133Z DEBUG @wdio/utils:shim: Finished to run "afterCommand" hook in 0ms
[0-0] 2023-01-10T08:48:21.173Z DEBUG @wdio/utils:shim: Finished to run "before" hook in 97ms
[0-0] 2023-01-10T08:48:21.180Z INFO webdriver: COMMAND enablePerformanceAudits()
[0-0] 2023-01-10T08:48:21.180Z DEBUG @wdio/utils:shim: Finished to run "beforeCommand" hook in 0ms
[0-0] 2023-01-10T08:48:21.181Z DEBUG @wdio/utils:shim: Finished to run "afterCommand" hook in 1ms
[0-0] 2023-01-10T08:48:21.181Z INFO webdriver: RESULT undefined
[0-0] 2023-01-10T08:48:21.184Z INFO @wdio/devtools-service:TraceGatherer: Start tracing frame with url https://www.google.fr
[0-0] 2023-01-10T08:48:21.291Z DEBUG @wdio/utils:shim: Finished to run "beforeCommand" hook in 106ms
[0-0] 2023-01-10T08:48:21.291Z DEBUG @wdio/utils:shim: Finished to run "beforeCommand" hook in 0ms
[0-0] 2023-01-10T08:48:21.292Z INFO webdriver: COMMAND navigateTo("https://www.google.fr/")
[0-0] 2023-01-10T08:48:21.293Z INFO webdriver: [POST] http://localhost:9515/session/195eecb376d5878773d49b99476582e4/url
[0-0] 2023-01-10T08:48:21.293Z INFO webdriver: DATA { url: 'https://www.google.fr/' }
[0-0] 2023-01-10T08:48:21.503Z INFO @wdio/devtools-service:TraceGatherer: Page load detected: https://www.google.fr/, set frameId CBC8D29D258793A24A6BBC215C66C7B7, set loaderId F6556BD66199E38DA0550776D4541630
[0-0] 2023-01-10T08:48:21.822Z INFO @wdio/devtools-service:TraceGatherer: page load happen to quick, waiting 14362ms more
[0-0] 2023-01-10T08:48:21.825Z INFO webdriver: RESULT null
[0-0] 2023-01-10T08:48:21.825Z INFO @wdio/devtools-service: Wait until tracing for command navigateTo finishes
[0-0] 2023-01-10T08:48:36.185Z INFO @wdio/devtools-service:TraceGatherer: Tracing completed after 15001ms, capturing performance data for frame CBC8D29D258793A24A6BBC215C66C7B7
[0-0] 2023-01-10T08:48:36.319Z INFO @wdio/devtools-service:TraceGatherer: Replace mainFrame process id 5192 with actual thread process id 5191
[0-0] 2023-01-10T08:48:36.319Z INFO @wdio/devtools-service:TraceGatherer: Tracing for CBC8D29D258793A24A6BBC215C66C7B7 completed
[0-0] 2023-01-10T08:48:36.319Z INFO @wdio/devtools-service: Disable throttling
[0-0] 2023-01-10T08:48:36.321Z INFO @wdio/devtools-service: continuing with next WebDriver command
[0-0] 2023-01-10T08:48:36.321Z DEBUG @wdio/utils:shim: Finished to run "afterCommand" hook in 14496ms
[0-0] 2023-01-10T08:48:36.321Z DEBUG @wdio/utils:shim: Finished to run "afterCommand" hook in 0ms
[0-0] 2023-01-10T08:48:36.321Z INFO webdriver: COMMAND getMetrics()
[0-0] 2023-01-10T08:48:36.321Z DEBUG @wdio/utils:shim: Finished to run "beforeCommand" hook in 0ms
[0-0] 2023-01-10T08:48:36.322Z DEBUG @wdio/utils:shim: Finished to run "afterCommand" hook in 0ms
[0-0] Error in "test perf.should get the metrics"
Error: Unable to identify the main resource
[0-0] 2023-01-10T08:48:36.325Z INFO webdriver: COMMAND disablePerformanceAudits()
[0-0] 2023-01-10T08:48:36.325Z DEBUG @wdio/utils:shim: Finished to run "beforeCommand" hook in 0ms
[0-0] 2023-01-10T08:48:36.325Z DEBUG @wdio/utils:shim: Finished to run "afterCommand" hook in 0ms
[0-0] 2023-01-10T08:48:36.325Z INFO webdriver: RESULT undefined
[0-0] 2023-01-10T08:48:36.325Z DEBUG @wdio/utils:shim: Finished to run "after" hook in 0ms
[0-0] 2023-01-10T08:48:36.326Z DEBUG @wdio/utils:shim: Finished to run "beforeCommand" hook in 0ms
[0-0] 2023-01-10T08:48:36.326Z INFO webdriver: COMMAND deleteSession()
[0-0] 2023-01-10T08:48:36.326Z INFO webdriver: [DELETE] http://localhost:9515/session/195eecb376d5878773d49b99476582e4
[0-0] 2023-01-10T08:48:36.380Z INFO webdriver: RESULT null
[0-0] 2023-01-10T08:48:36.380Z DEBUG @wdio/utils:shim: Finished to run "afterCommand" hook in 0ms
2023-01-10T08:48:36.497Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 1
[0-0] FAILED in chrome - file:///test/specs/example.e2e.ts
2023-01-10T08:48:36.498Z INFO @wdio/cli:launcher: Run onWorkerEnd hook
2023-01-10T08:48:36.499Z DEBUG @wdio/cli:utils: Finished to run "onWorkerEnd" hook in 0ms
2023-01-10T08:48:36.499Z INFO @wdio/cli:launcher: Run onComplete hook
2023-01-10T08:48:36.499Z DEBUG @wdio/cli:utils: Finished to run "onComplete" hook in 0ms
"spec" Reporter:
------------------------------------------------------------------
[chrome 108.0.5359.124 mac os x #0-0] Running: chrome (v108.0.5359.124) on mac os x
[chrome 108.0.5359.124 mac os x #0-0] Session ID: 195eecb376d5878773d49b99476582e4
[chrome 108.0.5359.124 mac os x #0-0]
[chrome 108.0.5359.124 mac os x #0-0] Β» /test/specs/example.e2e.ts
[chrome 108.0.5359.124 mac os x #0-0] test perf
[chrome 108.0.5359.124 mac os x #0-0] β should get the metrics
[chrome 108.0.5359.124 mac os x #0-0]
[chrome 108.0.5359.124 mac os x #0-0] 1 failing (15.2s)
[chrome 108.0.5359.124 mac os x #0-0]
[chrome 108.0.5359.124 mac os x #0-0] 1) test perf should get the metrics
[chrome 108.0.5359.124 mac os x #0-0] Unable to identify the main resource
[chrome 108.0.5359.124 mac os x #0-0] Error: Unable to identify the main resource
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:19
2023-01-10T08:48:36.500Z INFO @wdio/local-runner: Shutting down spawned worker
2023-01-10T08:48:36.750Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2023-01-10T08:48:36.751Z INFO @wdio/local-runner: shutting down
Code of Conduct
- I agree to follow this projectβs Code of Conduct
Is there an existing issue for this?
- I have searched the existing issues
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19 (6 by maintainers)
Sounds good to me, closing. If anyone still encounters issue, please feel free to raise a new issue and provide a reproducible example, thank you!
Re: the comments I put.
Erwin Heitzman (very helpfully) resolved the issue I was seeing, which was entirely a consequence of running against Node 18/19.
@erwinheitzman , it works fine with node18 and latest wdio. I guess the last update solved the issue π !
@cfrensley-cmtl You should try this combo (node18 + webdriverio 8.2.1)
A good place to start looking is within the devtools service where this method is implemented. You would need some knowledge about the Chrome DevTools protocol but nothing here that is impossible to figure out. Please understand that my time working on the project is limited and allocated to what is most important (from my POV). So I am not sure when I will get to this. Any contributions with a fix for this would be very much appreciated.