Skip to content
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

Merged
merged 14 commits into from
Oct 24, 2024

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Oct 21, 2024

Came out of #33146. frameLocator('iframe') is synonymous to locator('iframe').contentFrame(), but our locator <-> selector processing can't handle frameLocator('iframe') well. This PR fixes that by adding a special case and respecting both syntaxes the same.

@Skn0tt Skn0tt requested a review from dgozman October 21, 2024 15:28
@Skn0tt Skn0tt self-assigned this Oct 21, 2024

This comment has been minimized.

Copy link
Contributor

@dgozman dgozman left a 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.

@Skn0tt
Copy link
Member Author

Skn0tt commented Oct 22, 2024

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?

@dgozman
Copy link
Contributor

dgozman commented Oct 22, 2024

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.

@Skn0tt
Copy link
Member Author

Skn0tt commented Oct 22, 2024

addressed your feedback

@Skn0tt Skn0tt changed the title Fix iframe locator generator fix(locator generator): handle frameLocator() and locator().contentFrame() Oct 22, 2024
locatorPartWithEngine = factory.generateLocator(base, 'default', selectorPart);
}

if (nextPart && nextPart.name === 'internal:control' && (nextPart.body as string) === 'enter-frame') {
Copy link
Contributor

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?

Copy link
Member Author

@Skn0tt Skn0tt Oct 22, 2024

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.

Copy link
Contributor

Test results for "tests 1"

2 flaky ⚠️ [playwright-test] › ui-mode-test-output.spec.ts:80:5 › should show console messages for test @macos-latest-node18-1
⚠️ [installation tests] › playwright-electron-should-work.spec.ts:44:5 › should work when wrapped inside @playwright/test and trace is enabled @package-installations-macos-latest @playwright/test

36570 passed, 626 skipped
✔️✔️✔️

Merge workflow run.

@Skn0tt Skn0tt merged commit 69f56b9 into microsoft:main Oct 24, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants