browsertime icon indicating copy to clipboard operation
browsertime copied to clipboard

The param scriptInput.visualElements doesn't work well with pseudo classes tr:first-child

Open polarnik opened this issue 7 months ago • 2 comments

Have you read the documentation?

URL

https://youtrack.jetbrains.com

What are you trying to accomplish

Summary

I would like to use pseudo classes like tr:first-child for the selector --scriptInput.visualElements.

Steps

Pass the argument --scriptInput.visualElements VisualElementName:tr:first-child

Actual result

The selector will be tr instead of tr:first-child because https://github.com/sitespeedio/browsertime/blob/v24.7.0/browserscripts/pageinfo/visualElements.js#L92C1-L95C61

      const parts = nameAndSelector.split(':');
      const type = parts[0];
      const selector = parts[1];
      const element = document.body.querySelector(selector);

Expected result

const selector = nameAndSelector.split(':', 2);

What browser did you use?

Chrome

How to reproduce

Pass the argument `--scriptInput.visualElements VisualElementName:tr:first-child`

Log output


polarnik avatar May 28 '25 08:05 polarnik

const selector = nameAndSelector.slice(nameAndSelector.indexOf(':') + 1);

Amerousful avatar May 28 '25 10:05 Amerousful

https://github.com/sitespeedio/browsertime/pull/2298

Amerousful avatar May 31 '25 12:05 Amerousful