Skip to content

The parameter --script works before the test. But the documentation is about collect metrics and run after the page has finished loading #2296

@polarnik

Description

@polarnik

Have you read the documentation?

URL

https://youtrack.jetbrains.com

What are you trying to accomplish

Summary

sitespeedio/sitespeed.io:37.5.1-plus1

Steps

I read the docs about the param:

--browsertime.script, --script Add custom Javascript that collect metrics and run after the page has finished loading. Note that --script can be passed multiple times if you want to collect multiple metrics. The metrics will automatically be pushed to the summary/detailed summary and each individual page + sent to Graphite

and created a file /metrics.js with the content:

return (function() {
    console.log("metrics.js");
    try {
        const entries = performance.getEntriesByType("navigation");
        const entry = entries[0];

        console.log(`metrics.js: entry: ${entry}`);
        console.log(`metrics.js: entries: ${entries}`);
    } catch (e) {}
})();

and passes a view params to the test:

--browsertime.script /metrics.js

Actual result

I see metrics.js messages before the test, but not after the page has finished loading

Expected result

I will see metrics.js messages after the page has finished loading, or I will see an actual documentations about how to add custom measurements

What browser did you use?

Chrome

How to reproduce

--browsertime.script /metrics.js

Log output

STDOUT: Chromium 136.0.7103.25 
STDOUT: Mozilla Firefox 136.0.4
STDOUT: Architecture: aarch64
STDOUT: [2025-05-30 15:10:59] INFO: Versions OS: linux 6.10.14-linuxkit nodejs: v22.13.0 sitespeed.io: 37.5.1 browsertime: 24.6.0 coach: 8.1.1
STDOUT: [2025-05-30 15:10:59] INFO: The following plugins are enabled: assets, browsertime, budget, coach, domains, harstorer, html, lateststorer, metrics, pagexray, remove, text, thirdparty
STDOUT: metrics.js
STDOUT: metrics.js: entry: undefined
STDOUT: metrics.js: entries: 
STDOUT: [2025-05-30 15:10:59] INFO: Running tests using Chrome - 1 iteration(s)
STDOUT: [2025-05-30 15:11:00] INFO: Testing url https://youtrack.jetbrains.com/ iteration 1
STDOUT: [2025-05-30 15:11:11] INFO: Take after page complete check screenshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions