Why might this test fail even if the button click works?
medium
A. The selector 'button.submit' is incorrect if the button has id 'submit', not class 'submit'
B. The expect assertion syntax is invalid and will cause a syntax error
C. page.goto is missing await causing navigation failure
D. toHaveText cannot be used with page.locator
Solution
Step 1: Check selector correctness
'button.submit' selects a button with class 'submit', but if button has id 'submit', selector should be 'button#submit'.
Step 2: Verify assertion and syntax
expect with toHaveText on page.locator is valid syntax in Playwright.
Final Answer:
The selector 'button.submit' is incorrect if the button has id 'submit', not class 'submit' -> Option A
Quick Check:
Selector must match element attribute type [OK]
Hint: Match selector type: # for id, . for class [OK]
Common Mistakes:
Using class selector when element has id
Missing await on async calls
Misunderstanding Playwright assertion syntax
5. You want to write a Playwright test for a Svelte app that fills a form with name and email, submits it, and checks for a success message. Which sequence of actions is correct?