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