-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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(inspector): highlight xpath/css locators without engine prefix #27742
Conversation
This comment has been minimized.
This comment has been minimized.
3f41d98
to
8d9b9f2
Compare
8d9b9f2
to
3eed058
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Max Schmitt <max@schmitt.mx>
This comment has been minimized.
This comment has been minimized.
if (typeof selector === 'string') | ||
return selector; | ||
return selector.parts.map((p, i) => { | ||
const prefix = p.name === 'css' ? '' : p.name + '='; | ||
let hideEngine = false; | ||
if (!forceEngineName) { |
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.
While reading this, I realized that we cannot hide engine for the "capture" part.
if (!forceEngineName) { | |
if (!forceEngineName && i !== selector.capture) { |
if (typeof selector === 'string') | ||
return selector; | ||
return selector.parts.map((p, i) => { | ||
const prefix = p.name === 'css' ? '' : p.name + '='; | ||
let hideEngine = false; |
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.
nit: for readability, I'd recommend includeEngine
instead.
Test results for "tests 1"7 flaky25934 passed, 603 skipped Merge workflow run. |
…icrosoft#27742) Motivation: As of today when a user inspects a Locator which is a xpath, it won't work if the user has not prefixed it with `xpath=` because we internally compare the given with the generated locator. Works: `locator('xpath=//div[contains(@Class, "foo")]')` Does not work: `locator('//div[contains(@Class, "foo")]')` Relates microsoft#27707 (comment) Fixes microsoft/playwright-dotnet#2718 (comment) --------- Signed-off-by: Max Schmitt <max@schmitt.mx>
Motivation: As of today when a user inspects a Locator which is a xpath, it won't work if the user has not prefixed it with
xpath=
because we internally compare the given with the generated locator.Works:
locator('xpath=//div[contains(@class, "foo")]')
Does not work:
locator('//div[contains(@class, "foo")]')
Relates #27707 (comment)
Fixes microsoft/playwright-dotnet#2718 (comment)