-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(locator generator): handle frameLocator()
and locator().contentFrame()
#33208
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple comments.
Btw, here is the previous implementation that was removed: https://github.com/microsoft/playwright/pull/32697/files#diff-ffdc452be25f5c91f4cb081974256b611978f6bde6aff0ee018ea511312e33b0, just in case you'd like to see how it was.
packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts
Outdated
Show resolved
Hide resolved
packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts
Outdated
Show resolved
Hide resolved
Interesting! So it looks like we used to only handle one of the two options. Then we swapped it around to handle the other option. And with this PR, we now handle both options. Is that right? |
Yep. |
addressed your feedback |
frameLocator()
and locator().contentFrame()
locatorPartWithEngine = factory.generateLocator(base, 'default', selectorPart); | ||
} | ||
|
||
if (nextPart && nextPart.name === 'internal:control' && (nextPart.body as string) === 'enter-frame') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking again, I see that we might be missing some cases. For example, page.getByTitle('iframe title').contentFrame()
- does it correctly handle this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch, it does not. I've revised the approach in e1e9b66 to go back one produced token and update that in retrospect. This makes the change much smaller as well, really liking it. Makes the code a little more hairy though because it mutates across iterations.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts
Outdated
Show resolved
Hide resolved
packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts
Outdated
Show resolved
Hide resolved
Test results for "tests 1"2 flaky36570 passed, 626 skipped Merge workflow run. |
Came out of #33146.
frameLocator('iframe')
is synonymous tolocator('iframe').contentFrame()
, but our locator <-> selector processing can't handleframeLocator('iframe')
well. This PR fixes that by adding a special case and respecting both syntaxes the same.