browsertime icon indicating copy to clipboard operation
browsertime copied to clipboard

pageCompleteCheck doesn't work when passing a script file as an argument

Open harshavarma opened this issue 6 years ago • 3 comments

Hi there,

The documentation here (https://www.sitespeed.io/documentation/browsertime/configuration/) says that a script file can be passed but it doesn't work. The script inside the file is never executed. I know I can use inline JS but just wanted to raise the inconsistency. I'm using the docker version on Ubuntu 18.04.

Also, this unit test here (https://github.com/sitespeedio/browsertime/blob/34ecdc435aa9c481e723436da3a61e2dbf2e3efd/test/browserTests/engineTests.js#L239) seems to indicate that a script file is indeed supported?

harshavarma avatar Aug 07 '19 21:08 harshavarma

Hi @harshavarma can you add an example how you run so I can easily reproduce? Thanks Peter

soulgalore avatar Aug 08 '19 17:08 soulgalore

Hi Peter,

This is what I'm currently using and it works as expected. docker run --rm -v "$(pwd)":/sitespeed.io ${DOCKER_IMAGE} ${WEBSITE_URL} -n 1 --browsertime.pageCompleteCheck "return document.querySelector('.btn--primary') != null"

However, if I move the same inline code to a file, it doesn't. I tried wrapping it in a IIFE and it still didn't work. docker run --rm -v "$(pwd)":/sitespeed.io ${DOCKER_IMAGE} ${WEBSITE_URL} -n 1 --browsertime.pageCompleteCheck pageCompleteCheck.js

Also, the inline code fails when I use docker run --rm -v "$(pwd)":/sitespeed.io ${DOCKER_IMAGE} ${WEBSITE_URL} -n 1 --browsertime.pageCompleteCheck "return !!document.querySelector('.btn--primary')"

The !! operator seems to be causing an issue. I tried escaping it but when I used --verbose mode, I saw that the escape characters are getting escaped.

harshavarma avatar Aug 08 '19 22:08 harshavarma

Hi @harshavarma I think the docs are wrong or the code, sorry. There's a miss there, I can't see in the code that we actually try to read the file. I'll try to fix that for the next release.

Best Peter

soulgalore avatar Aug 13 '19 06:08 soulgalore

This was fixed but then broken again when we moved to ESM.

soulgalore avatar Dec 17 '23 04:12 soulgalore

This has finally been fixed again in BT 20.

soulgalore avatar Dec 22 '23 05:12 soulgalore