Quiz: Debugging
Why This Matters
A quick check that this module’s ideas hold up before you move on. Answer each question yourself before you open the answer.
Quiz
1. A test fails only in CI. What do you look at first?
- A. Rerun it locally until it fails
- B. The trace of the failed run
- C. Increase the timeout
- D. Add
waitForTimeout(5000)
Show answer
B. The trace shows every action, page snapshot, network call and console message from the failing run itself. Guessing with timeouts hides the cause.
Quiz
2. Playwright reports strict mode violation … resolved to 5 elements. What does it mean?
- A. The page has a JavaScript error
- B. The locator matched more than one element
- C. The test used a deprecated API
- D. The assertion timed out
Show answer
B. Actions need exactly one element. Make the locator more specific, for example by finding the right product card first. The error lists every match, with a locator for each.
Quiz
3. A test waits 30 seconds and the call log ends with waiting for getByTestId('search-box'). Most likely cause?
- A. The network is slow
- B. The locator does not match anything on the page
- C. The test is flaky
- D. The browser crashed
Show answer
B. Actions wait for their element to appear. A locator that never matches turns into a wait until the test timeout. The screenshot tells you whether the element is really missing or the locator is wrong.
Quiz
4. toHaveText fails with the same unexpected value on all 11 attempts. What should you do before changing the expected value?
- A. Increase the timeout
- B. Check which side is right: work out the correct value from the requirements
- C. Add a retry
- D. Change the locator
Show answer
B. A stable, unexpected value means the page and the test disagree. Sometimes the test is wrong (a sum done by hand); sometimes it found a real bug. Changing the expectation without checking turns a bug report into a green test.
Quiz
5. The config says trace: "on-first-retry" and retries: 2 in CI. A test fails once and passes on its first retry. What do you get?
- A. Nothing: the test passed
- B. A trace of the retry, and the test marked as flaky
- C. Three traces
- D. A screenshot only
Show answer
B. The first retry is recorded, and a test that needed a retry to pass is reported as flaky. Module 7 is about not ignoring those.
Quiz
6. What is the main thing to change when you turn a codegen recording into a test?
- A. Rename the variables
- B. Add the assertions; a recording only contains actions
- C. Replace every locator with XPath
- D. Nothing; recordings are ready to use
Show answer
B. A recording passes as long as nothing crashes. The assertions are what make it a test. Also replace the full URL with a path, drop redundant clicks and give the test a name that says what it checks.