BackstopJS icon indicating copy to clipboard operation
BackstopJS copied to clipboard

Global hideSelectors

Open The-Code-Monkey opened this issue 3 years ago • 4 comments

So it seems that per scenario you can add

"hideSelectors": ["div[data-autoid='station_clock']", "button[data-autoid='status_button']"]

but this means i have to duplicate this line on every test, is there a way that I can set this globally for each test similar to onBeforeScript.

The-Code-Monkey avatar May 04 '21 15:05 The-Code-Monkey

Yes, you can do this easily in an onReady script. See puppeteer docs for more info.

garris avatar May 05 '21 05:05 garris

Why do we have to write the code and do it manually when it is done automatically for us if we put it in a scenario? shouldn't it be possible to check the global stuff before you take the screenshot?

The-Code-Monkey avatar May 05 '21 07:05 The-Code-Monkey

Just had the same issue and had to copy-paste the hideSelectors list into each scenario, while I always need to have certain elements hidden / invisible. Typical examples are Cookie Banners, Slideshows, Chats, ...

+1 to allow defining

  • hide
  • removeSelectors

also globally and applying them on all scenarios. I guess this is a quite typical use-case. :)

Thanks a lot!

JPustkuchen avatar Jul 15 '22 07:07 JPustkuchen

I created a general feature request for this: https://github.com/garris/BackstopJS/issues/1432 So perhaps this particular issue can be closed and people could vote on the general issue?

JPustkuchen avatar Aug 10 '22 05:08 JPustkuchen