fix(locator generator): handle frameLocator() and locator().contentFrame()#33208
Conversation
This comment has been minimized.
This comment has been minimized.
dgozman
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.