QA PRACTICE•PATTERNS

Locator Practice HubTopics / Best-practice patterns

Lesson 20 / 20 · Beginner

Best-practice patterns

Review a practical locator decision checklist.

8 min

Not completed

Concept

Locator karar sırası: role+name > label > placeholder > testid > scoped CSS > text > XPath > index. Bu mutlak kural değil; ürünün gerçek contract’ını ve bakım maliyetini değerlendiren bir başlangıç rehberidir.

Prerequisites: All previous topics

Live demo

Try the locator

Scoped to lesson demo

Try the locator against the live demo.

Good

Her locator için stabilite, okunabilirlik ve actionability kontrolü yap.

Avoid

Bir framework’te çalışan her selector’ı diğerine birebir taşımak.

Why

Araç syntax’ı değişebilir; locator tasarım ilkeleri korunur.

Real-world trap

XPath her şeyi çözmez; iframe ve Shadow DOM için context sınırları ayrıca geçerlidir.

Framework comparison

Playwright

page.locator("[data-testid='patterns-demo'] button")

Selenium

driver.findElement(By.cssSelector("[data-testid='patterns-demo'] button"))

Cypress

cy.get("[data-testid='patterns-demo'] button")

Mini quiz

Öncelik sırasının amacı nedir?