Closed drodenberg closed 3 years ago
Still working on this. Looking at tests
@drodenberg thanks for contributing. From your description I still do not understand what we are actually doing here. Can you provide a clear, point by point description of the use case
I know only read "i want to tweak some setting" but I have no idea of the context and if this might be useful for others.
Thanks for responding. So the issue we have is that the finder
lib is generating selectors with the child combinator >
that include styled component classes. These are unreliable because a change of CSS source will re-generate the class name with a new unique id. This new setting makes it possible to generate "shallow" or non-nested selectors based on data attributes which will not be effected by re-generated classes.
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('https://demo.ol-kit.com/?view=39.000000,-96.000000,5.00,0.00')
await page.setViewport({ width: 1680, height: 916 })
await page.waitForSelector('.MuiPaper-root > .MuiTabs-root > .MuiTabs-scroller > .sc-paXsP > .MuiTabs-flexContainer > [data-testid="LayerPanel.openTab"]')
await page.click('.MuiPaper-root > .MuiTabs-root > .MuiTabs-scroller > .MuiTabs-flexContainer > [data-testid="LayerPanel.openTab"]')
await page.waitForSelector('.MuiPaper-root > .MuiTabs-root > .MuiTabs-scroller > .sc-paXsP > .MuiTabs-flexContainer > [data-testid="LayerPanel.openTab"]')
await page.click('.MuiPaper-root > .MuiTabs-root > .MuiTabs-scroller > .MuiTabs-flexContainer > [data-testid="LayerPanel.openTab"]')
await browser.close()
})()
Notice the styled component generated classnames contained within those selectors: .sc-paXsP
What we really want is:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('https://demo.ol-kit.com/?view=39.000000,-96.000000,5.00,0.00')
await page.setViewport({ width: 1680, height: 916 })
await page.waitForSelector('[data-testid="LayerPanel.openTab"]')
await page.click('[data-testid="LayerPanel.openTab"]')
await page.waitForSelector('[data-testid="LayerPanel.openTab"]')
await page.click('[data-testid="LayerPanel.openTab"]')
await browser.close()
})()
Let us know if this doesn't make sense
@glenselle This clears things up a lot! Can you turn the PR into a draft until it is ready for review and I will gladly review it.
Hi @drodenberg Do you by chance have some time to look into this.
@tnolet Without this, the CUSTOM DATA ATTRIBUTE
feature doesn't seem very useful.
pinging @ianaya89 to have a look at this
@xmile1 @tnolet we already merged a PR (#130) related to this.
Basically, when data-
attribute is in the element (and you set the data-
attr option) we will assume the attribute as a unique identifier (the same applies for id
).
You will not see nested selectors for those cases.
We are already working on other improvements and we will ship them soon 🤞
Closing due inactivity. Feel free to open it again whenever is ready
Pull Request Template
Description
Want the ability to pass minimum values for data-attribute selectors using the finder methods properties of
optimizedMinLength
andseedMinLength
. We added a new setting calledtreat data attributes as unique (this will not generate nested selectors)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist:
npm run lint
passes with no errors.npm run test
passes with no errors.