Skip to content

test(sample): make the first test people read show the locator API - #1

Merged
shossain786 merged 1 commit into
masterfrom
docs/sample-test-shows-locator-api
Aug 27, 2026
Merged

shossain786 merged 1 commit into
masterfrom
docs/sample-test-shows-locator-api

Conversation

@shossain786

Copy link
Copy Markdown
Contributor

The problem

SampleTest is the file a newcomer opens first. It was two identical copies of:

getDriver().get("https://google.com");
assertEquals(getDriver().getTitle(), "Google");

plus a block of commented-out dead code.

It ignored baseUrl and open(), navigated off the demo app to a site that blocks automation, and demonstrated nothing the framework does. The shop window showed the opposite of the pitch — while LocatorApiDemoTest and SemanticLocatorDemoTest, which do show it, sit deeper in the tree where nobody looks first.

The change

Two tests against the demo app using getByLabel, getByRole, getByTestId and web-first assertions, with a class comment stating exactly what is absent — driver setup, WebDriverWait, CSS selectors, XPath — and pointing at LocatorApiDemoTest for the full surface.

Raw Selenium is still not hidden; the comment says so and getDriver() remains available.

Verification

2/2 green against panjatan.netlify.app in real Chrome under xvfb, and the surrounding suite stayed green in the same run (11/11).

Locators were chosen from the demo app's actual markup — <label for="username">Username:</label>, <button aria-label="Login">, data-testid="login-submit-btn" and data-testid="remember-checkbox" — not guessed.

Pairs with

seleniumboot/selenium-boot#40, which fixes the same gap in the README quickstart.

SampleTest is the file a newcomer opens first, and it was two identical copies of

    getDriver().get("https://google.com");
    assertEquals(getDriver().getTitle(), "Google");

plus a block of commented-out dead code. It ignored baseUrl and open(), navigated
off the demo app to a site that blocks automation, and demonstrated nothing the
framework does. The shop window showed the opposite of the pitch — while
LocatorApiDemoTest and SemanticLocatorDemoTest, which do show it, sit deeper in
the tree where nobody looks first.

Now: two tests against the demo app using getByLabel, getByRole, getByTestId and
web-first assertions, with a class comment stating exactly what is absent (driver
setup, WebDriverWait, CSS/XPath) and pointing at LocatorApiDemoTest for the rest.

Verified: 2/2 green against panjatan.netlify.app in real Chrome via xvfb, and the
surrounding suite stayed green (11/11 in the same run).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@shossain786
shossain786 merged commit 3be99a2 into master Aug 27, 2026
@shossain786
shossain786 deleted the docs/sample-test-shows-locator-api branch August 27, 2026 02:04
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.

1 participant