screener-script-sanitizer
v1.0.2
Published
A utility to convert styled-component selectors with dynamic hashes to wildcard selectors which won't break on new hash generation
Downloads
5
Maintainers
Readme
What's this for?
Screener can't handle class names generated by Styled-components because of the ever changing hashes. This causes screener scripts to break everytime a new version of the app is deployed. Unfortunaly the fix for this is expensive on the app side, but this package will help us mitigate the issue from the screener side
This package takes a selinium script (basically a list of events, like click here, type this in) and replaces all fragile styled-component class selectors for more resiliant wildcard selectors.
In short, it turns Selectors like this: div:nth-of-type(5) > div.ListItem__Item-s1ecg881-1 > a.Link__StyledLink-dvftiw-0
Into something this: div:nth-of-type(5) > div[class^=\"ListItem__Item-\"] > a[class^=\"Link__StyledLink-\"]
This prevents the hash changes from breaking the selector
How to use!
install this module globally with npm install -g screener-script-sanitizer
Now you should be able to run screener-script-sanitizer <path/to/file>
from your terminal
- export your script, save it to a file:
scriptName.json
- run
screener-script-sanitizer
./path/to/scriptName.json` - Creates a file called
./scriptName-sanitized.json
- Now re-upload that sanitized version in place of the one you exported (edited)
You'll have to run this same process on every Script made in screener. I also believe that edits to already converted scripts might require you to export and re-run the sanatizer.