Playwright Junior interview questions and answers

75 questions for a Playwright (Junior) interview - with correct answers, explanations and links to the docs.

Take this quiz
  1. 1.Which command creates a new Playwright Test project with a config and an example test?
  2. 2.What does npx playwright install do?
  3. 3.Which three browser engines does Playwright Test support out of the box?
  4. 4.Which command runs all Playwright tests in the project?
  5. 5.How do you run Playwright tests with a visible browser window?
  6. 6.How do you run only tests whose title contains "login"?
  7. 7.What does npx playwright show-report open?
  8. 8.What is UI Mode (npx playwright test --ui)?
  9. 9.What does npx playwright test --debug do?
  10. 10.Where are global settings like baseURL, retries and projects defined?
  11. 11.What does setting baseURL in the config allow?
  12. 12.What is the page argument in a Playwright test?
  13. 13.Why must Playwright actions and assertions be awaited?
  14. 14.Which locator does Playwright recommend first for a button?
  15. 15.Which locator is best for an input that has a <label>?
  16. 16.When is getByPlaceholder a reasonable choice?
  17. 17.Which attribute does getByTestId('submit') look for by default?
  18. 18.What does getByText('Welcome') match by default?
  19. 19.Which locator finds an image by its alt text?
  20. 20.When does Playwright resolve a locator to an element?
  21. 21.What happens when a locator used in click() matches three elements?
  22. 22.How do you pick the second row of a list deliberately?
  23. 23.How do you find a product card that contains the text "Laptop"?
  24. 24.What does chaining locators like this do?
  25. 25.Which method types text into an input, replacing its value?
  26. 26.When would you use pressSequentially() instead of fill()?
  27. 27.How do you press Enter in a focused search field?
  28. 28.How do you tick a checkbox in Playwright?
  29. 29.How do you pick an option in a native <select>?
  30. 30.How do you upload a file through an <input type="file">?
  31. 31.Which method moves the mouse over an element to show its tooltip?
  32. 32.What does Playwright check before it clicks an element?
  33. 33.What does toHaveText check?
  34. 34.Which assertion checks the current value of an input?
  35. 35.Which assertion checks that the browser is on the dashboard page?
  36. 36.How do you check that a list shows exactly 3 items?
  37. 37.How do you assert that an error message is NOT shown?
  38. 38.Which assertion checks that a button is disabled?
  39. 39.What is the default timeout for expect assertions in Playwright Test?
  40. 40.What is the default timeout for a whole Playwright test?
  41. 41.How do you run only one test while developing?
  42. 42.What does test.skip() do?
  43. 43.What does test.fixme() mean?
  44. 44.What does test.fail() mean?
  45. 45.How can you tag a test to run a smoke subset?
  46. 46.What does test.describe do?
  47. 47.Where would you put page.goto('/') that every test in a file needs?
  48. 48.What do projects in playwright.config.ts usually describe?
  49. 49.How do you run tests only in the Firefox project?
  50. 50.How do you emulate an iPhone in a Playwright project?
  51. 51.How do you set the browser window size for tests?
  52. 52.How do you take a screenshot of the page?
  53. 53.What does screenshot: 'only-on-failure' in use do?
  54. 54.Why is trace: 'on-first-retry' a common setting?
  55. 55.What happens to a window.alert() dialog by default in Playwright?
  56. 56.How do you accept a confirm() dialog?
  57. 57.How do you work with a link that opens a new tab?
  58. 58.How do you click a button inside an <iframe>?
  59. 59.How do you test a file download?
  60. 60.Which built-in fixture sends HTTP requests without a browser page?
  61. 61.What does this API test check?
  62. 62.Why should each test be able to run on its own?
  63. 63.What is @playwright/test compared to the playwright package?
  64. 64.Which languages have official Playwright libraries?
  65. 65.What does the Playwright VS Code extension let you do?
  66. 66.What does page.waitForTimeout(2000) do and why avoid it?
  67. 67.What does toBeVisible() consider visible?
  68. 68.Which assertion checks an element's attribute?
  69. 69.What does getByRole('heading', { name: 'Pricing', exact: true }) add with exact?
  70. 70.Which assertion checks the page <title>?
  71. 71.Why is getByRole('link', { name: 'Docs' }) better than locator('a:nth-child(3)')?
  72. 72.What does reporter: 'html' in the config do?
  73. 73.What does the webServer option in the config do?
  74. 74.How do you pause a test at a certain line to inspect the page?
  75. 75.Where should Playwright tests get their test data?