Migrating Playwright Repos Without Orphan Locators
Author: Ashwin Kondapalli, Founder & CTO, LoopIQ Updated: October 15, 2026
The checkout team's Playwright repository is first in the migration wave. The specs look tidy: a pages/ folder with page-object classes, a fixtures/ folder, and about two hundred tests under tests/. The first trial import surfaces the real picture. Forty specs call page.locator('#btn-submit-v2') directly instead of using the cart page object. Six page-object getters point at elements that were removed two redesigns ago. Three specs import a helper from a sibling repository that nobody listed. Every one of those tests passed in CI last week.
Orphan locators are selectors that have lost their connection to a reviewed, owned definition. They come in three forms: a locator a migrated test still uses whose definition did not come along (a dangling reference), a locator definition that nothing uses anymore (dead code that still looks authoritative), and an inline copy of a selector that has drifted away from the page object it was copied from. Migrating a Playwright repository without orphan locators means resolving all three before the tests become reviewed release evidence: every selector a test uses has one owned home, every definition in that home is used or retired, and the mapping between them is recorded.
Why do orphan locators matter for release evidence?
A Playwright test that passes with an orphan locator still passes. The problem shows up later, and usually at the worst time.
Reviewers cannot tell what was tested. An inline page.locator('div:nth-child(3) > button') does not say which control it targets. A page-object getter named cart.submitOrderButton does.
Fixes land in one place but not the other. When the UI changes, someone updates the page object. The forty inline copies keep pointing at the old element, and some of them keep passing because a different element now matches.
Dead definitions mislead reviewers. A page object that still declares a removed field suggests coverage that no test exercises.
Dangling references break after migration. Helpers, fixtures, and page objects imported across repositories or through path aliases are easy to miss. The test worked in its original repository because the import resolved there.
Change history disappears. When locators are scattered through specs, nobody can answer "what changed in the checkout selectors between the last release and this one?"
Rule of thumb: a selector is part of the test's evidence. If you cannot say where it is defined, who owns it, and when it last changed, the test result it supports is weaker than it looks.
How do you find orphan locators before you migrate?
Do this in the source repository first. It is cheaper to fix locators where the tests already run than to discover the gaps after import.
List every locator call site. Search specs, page objects, and helpers for page.locator(, getByRole(, getByTestId(, getByText(, getByLabel(, and $(/$$( style calls. Record the file, the selector, and whether it sits in a page object or inline in a spec.
Resolve every import a spec relies on. Follow relative imports, tsconfig.json path aliases, and anything pulled from a shared package or sibling repository. Each one is a dependency that has to come along or be replaced.
Check custom fixtures. Fixtures defined with test.extend often construct page objects or log in through storageState. A spec can depend on a page object only through its fixture, so a plain import search will miss it.
Find inline duplicates. Group selectors by value. Any selector that appears inline in more than one spec, or inline and in a page object, is a duplicate to consolidate.
Find dead definitions. For each page-object getter or method, count the specs that use it. Zero callers means retire it or record why it stays.
Note the selector strategy. Role and label based locators, test IDs, CSS, and XPath behave differently when the UI changes. Check playwright.config.ts for a custom testIdAttribute so test-ID selectors are interpreted correctly after the move.
The output is a locator inventory: one row per selector, with where it is defined, where it is used, and a decision.
What should you do with each locator?
Give every row in the inventory exactly one decision.
Keep in its page object. The selector is defined once, used by at least one test, and targets an element that still exists.
Consolidate. An inline selector, or a duplicate, moves into the page object for that screen, and the specs call the page object instead. Do this before migration so the change is reviewed as ordinary code.
Bring the dependency. A page object, helper, or fixture from another repository or package is added to the migration scope, with an owner.
Replace the selector. Brittle CSS chains and positional XPath that only work by accident are rewritten to a role, label, or test-ID locator, then re-run to confirm they target the intended element.
Retire. A definition with no callers, or a test whose target screen no longer exists, is removed or left out of scope, with the decision recorded.
Two rules keep this honest. First, a test whose locators are not all resolved is not ready to migrate, however green it is in CI. Second, retirements are decisions, not deletions nobody noticed. Write them down so the coverage change is visible.
How should page objects be organized after migration?
Organize page objects so a reviewer can find the selector behind any step quickly.
One page object per screen or route. A checkout page object should not also hold account-settings selectors because the same developer wrote both.
Separate by ownership. If the payments team and the storefront team change their screens independently, give them separate page-object collections so a change in one does not quietly touch the other.
Name elements by intent. submitOrderButton and promoCodeInput read better in review than button3 or inputField.
Keep assertions in specs. Page objects locate and act. Specs state what should be true. Mixing the two makes it hard to see what a test actually proves.
Version the selectors. When a locator changes, the change should be reviewable and attributable, just like the test that uses it.
How this works in LoopIQ
Prerequisites: The LoopIQ GitHub App installed with only the in-scope repositories selected, the correct team context, and the applications or modules set up in Test Automation that the migrated tests will belong to.
What LoopIQ supports: Playwright with TypeScript is one of the supported frameworks, alongside Vibium, WebDriver BiDi through WebdriverIO, Selenium with Python or Java, Karate, pytest-bdd, and Behave. Per the current product notes, migration of existing tests from connected GitHub repositories includes dependency discovery, rescan identity, mapping review, and audit history. Only approved automation assets can be added to an executable suite or submitted to governed execution.
Page Object Repositories: Per the Test Automation help, an application or module can have multiple Page Object Repositories, each with multiple pages and immutable versions. You can rename, archive, restore, and reorder pages, browse versions, compare object and locator changes, and restore a previous version as a new version. Restoring does not erase history: LoopIQ creates a new immutable version and records an audit event. The help guidance recommends using Page Object Repositories instead of duplicating locators in generated tests, and capturing each application page separately within the appropriate repository. When you generate new Playwright or Selenium automation, you select a Page Object Repository, and you can optionally select a cross-page user journey.
Sequence (conceptual):
Build the locator inventory above in the source repository and fix inline duplicates, dangling imports, and dead definitions as reviewed pull requests.
Migrate the cleaned tests from the connected repository. Review the discovered dependencies and the proposed mappings to applications, modules, and requirements before accepting them. A dependency that was not discovered is a sign the inventory missed something.
Set up Page Object Repositories along the ownership boundaries you chose, with one page per screen, so new generated automation for the same application reuses stable locators instead of creating fresh copies.
Approve migrated automation assets individually, checking framework and language, stable page-object references, specific assertions, and that no secrets or sensitive personal data are in the test code.
Add approved tests to suites in Test library, run them against the intended environment and provider, and review step-level journey evidence in Runs & evidence, including locator references, screenshots, traces, and redacted failure messages.
When a repository is rescanned after later changes, review what changed rather than re-importing blind. Unresolved locators, unowned page objects, and retired tests stay open items in the testing section of the Release Compliance Dossier until someone resolves or excepts them.
Approvals and outputs: You get a reviewed locator inventory, migrated and approved tests, page objects with owners and version history, and runs whose evidence shows which locators were used. Tests produce evidence. They do not authorize a release. People make the go/no-go decision under policy. Release certification is an internal readiness record, not regulatory certification. Pricing is $4.99 per user per month.
Locator inventory excerpt (illustrative demo data)
Label: Illustrative demo data. Not a customer result.
#btn-submit-v2: inline in 40 specs under tests/checkout/ · also defined as CartPage.submitOrderButton · owner Checkout QA · Consolidate: specs call the page object, rewrite to a role locator for the "Place order" button
CartPage.giftWrapToggle: defined in pages/cart.ts · 0 callers · element removed in the spring redesign · Retire (recorded)
CheckoutPage.addressForm: defined in pages/checkout.ts · used through the checkoutPage fixture in fixtures/index.ts · owner Checkout QA · Keep
loginAs() helper: imported from @shop/test-utils in a sibling repository · used by 3 specs · owner Identity team · Bring the dependency into scope
//div[3]/div/span[2]: inline XPath in tests/checkout/promo.spec.ts · targets the promo discount label · Replace with a test-ID locator, re-run to confirm
[data-qa="tax-line"]: used in 12 specs · project sets testIdAttribute: 'data-qa' in playwright.config.ts · Keep, record the custom test-ID attribute in the migration notes
Use this before you migrate a Playwright repository:
Every locator call site in specs, page objects, and helpers is listed
Every import, path alias, and shared package a spec relies on resolves
Custom fixtures that build page objects or log in are traced
Inline and duplicated selectors are consolidated into page objects
Page-object members with no callers are retired or justified
Brittle positional selectors are replaced and re-run
Custom testIdAttribute settings are recorded
Each page-object collection has an owner
Discovered dependencies and mappings are reviewed after import
Migrated tests are approved individually before joining a suite
Unresolved locators and retirements are open items, not silent omissions
FAQ: quick answers
What is an orphan locator in Playwright? An orphan locator is a selector that has lost its link to an owned definition: a reference whose definition did not come along in a migration, a page-object member nothing uses, or an inline copy that has drifted from the page object it came from.
Should I fix locators before or after migrating a Playwright repository? Before. Consolidating inline selectors, resolving imports, and retiring dead page-object members in the source repository is ordinary code review. Discovering the same gaps after import is slower and easier to miss.
Can a passing Playwright test still have orphan locators? Yes. A test can pass because an outdated selector still happens to match an element, or because a dead page-object member is simply never called. Passing does not show that the selectors are owned or current.
Does LoopIQ support migrating Playwright tests from GitHub? Yes. LoopIQ supports Playwright with TypeScript, and its GitHub migration includes dependency discovery, rescan identity, mapping review, and audit history. Migrated tests still need review and approval before they can join an executable suite.
Does a passing migrated suite authorize a release? No. It produces evidence for the reviewers. People make the go/no-go decision under policy, and release certification is not regulatory certification.
Clean the locators, then move the tests
See a requirement become reviewed tests and execution evidence in LoopIQ, including how Playwright tests from your GitHub repositories land with owned page objects and versioned locators. Book a walkthrough: https://meet.brevo.com/ashwin-kondapalli.
Further reading: GitHub test migration checklist · Map GitHub Actions jobs to release evidence suites · Intent-based testing · From test results to release evidence · Test automation help · Pricing.
General information for engineering, quality, release, and compliance leaders. Not legal, audit, or regulatory advice.