Knowledge check
Ten questions on the decisions this course made, and why. Each answer comes with a short explanation.
1. A developer renames the login button's id from submit to login-button. In a suite built with page objects, what should need to change?
Locators live in exactly one place, the page object. If tests had to change, locator knowledge has leaked out of the page object layer.
2. On the practice site, #error is in the DOM from page load with opacity 0. In Playwright, await expect(page.locator('#error')).toBeVisible() right after goto() will...
Playwright's visibility check ignores opacity, so the assertion passes without any login attempt. The page object encodes the real meaning with #error.show. Selenium's isDisplayed() returns false for the same element.
3. Which check is acceptable inside a page object according to the Selenium documentation?
The docs say page objects should never make verifications, except checking that the page and critical elements loaded correctly, done at instantiation. Outcome checks belong in the test.
4. A login can succeed, or fail with an error on the same page. What is the cleanest page object API for that?
Separate methods make each expected outcome explicit in the test and give it a precise return type. A boolean flag plus internal assertions hides the expectation in the page object.
5. By.linkText("Practice") finds nothing in the practice site's menu, while the DOM text is "Practice". Why?
Selenium's link text uses what is rendered. Matching on DOM text (an XPath normalize-space() predicate, or Playwright's accessible name) keeps the locator independent of styling.
6. What is the main practical problem with @FindBy fields and PageFactory.initElements(driver, this)?
Page Factory still ships and is not deprecated, but its docs are in the Legacy section. Proxies re-find elements on each call; staleness only appears with @CacheLookup.
7. A TestNG class stores WebDriver driver in an instance field set in @BeforeMethod, and the suite runs with parallel="methods". What happens?
TestNG shares one instance across threads. A ThreadLocal driver, cleared with remove() after quit(), gives every thread its own browser.
8. With pytest-xdist (pytest -n 4), a fixture has scope="session". How often does it run?
xdist workers are separate processes, each with its own session. That isolation is why Python needs no ThreadLocal, and why "run once" setup must be designed for several workers.
9. A Playwright test fails, then passes on retry. Which setting makes the run fail anyway, so the flakiness is not hidden?
Playwright marks such tests "flaky", and failOnFlakyTests turns that into a failed run. Trace settings only control evidence; they do not change the result.
10. Your page objects need to run on a remote grid instead of local browsers. With the framework from this course, what changes?
Page objects only depend on a WebDriver or Page. Where that browser runs is decided in one place in the framework layer, which is the point of separating the layers.
Next, put the framework to work: our Selenium with Java and TestNG course goes deeper into the runner used in chapters 01-07, and the Playwright Test documentation shows the full configuration for running these specs on TestingBot.
You finished Page Object Model and Framework Design
Put what you learned into practice. Run your tests on 6100+ real browsers and physical iOS and Android devices.