arrow-left Back to topicQuizActionsCheck yourself1.You need to test an autocomplete that triggers suggestions after each keystroke. Which method should you use instead of fill()?page.keyboard.type() — simulates real keystroke eventslocator.pressSequentially() — types character by characterlocator.fill() with a delay option2.What does locator.fill('hello') do before setting the value?It appends 'hello' to whatever text is already in the field.It focuses the field and clears any existing value, then sets the new value.It clicks the field twice to select all, then types the new value.It does nothing if the field already has a value.3.What does locator.click() automatically do before firing the click event?It fires the click immediately without any waiting.It waits for the element to be visible, stable (no animations), and not obscured by another element — and scrolls it into view.It takes a screenshot of the element for the trace.It moves the mouse to the center of the page first, then to the element.4.You want to check a checkbox only if it is currently unchecked. Which method is most appropriate?locator.click() — clicking always toggles the checkbox.locator.check() — it verifies the current state and only clicks if the box is unchecked.locator.setChecked(false) — explicitly sets the state.locator.fill('true') — fill works for checkboxes too.5.How do you select an option in a native <select> dropdown by the text the user sees (not the value attribute)?locator.selectOption('Pending') — passing a string matches by value or visible text.locator.selectOption({ label: 'Pending' }) — passing an object with label matches by visible text.locator.click() then locator.getByText('Pending').click()locator.fill('Pending') — fill works for select elements.6.How do you attach a file to an <input type="file"> element in Playwright without opening the OS file picker?locator.click() — Playwright intercepts the file picker dialog automatically.page.on('filechooser', ...) combined with locator.click() — you must listen for the chooser event.locator.setInputFiles('path/to/file.pdf') — directly sets the file on the input without triggering the OS picker.locator.fill('path/to/file.pdf') — fill works for file inputs too.7.You want to send the keyboard combination Ctrl+A (select all) to an input field. Which code is correct?await locator.press('Ctrl', 'A')await locator.press('Control+a')await locator.keyboard('Ctrl+A')await locator.fill('Control+a')8.Which Playwright method handles HTML5 drag-and-drop (elements with the draggable attribute)?locator.dragTo(targetLocator) — drags from the source locator to a target locator.page.mouse.move() then page.mouse.down() then page.mouse.up() — only the low-level mouse API works.locator.click({ button: 'left', force: true }) held down.page.dragAndDrop(source, target) or locator.dragTo(target) — both work for HTML5 drag.Submit answersarrow-left PreviousLocatorsNavigationsNext arrow-right