Rayrun
← Back to Discord Forum

Fill not firing the same events as setValue or sendKeys in selenium?

reallymelloposted in #help-playwright
Open in Discord

Does playwright enter text differently than setValue or sendKeys would in selenium-based automation frameworks? The UI I am automating has a drop down list + text input control that let's one type an exact value or click expand and select the value from the list. The former is preferred for reliability and works in selenium, but calling .fill on the same locator in playwright causes the text to appear, but it doesn't register like it isn't triggering the same event so I am forced to select the value from the expanded drop down.

Is there a gotcha with .fill that people coming from selenium are aware of?

This thread is trying to answer question "Does Playwright's .fill method enter text differently than Selenium's setValue or sendKeys, and are there any known issues with .fill not triggering the same events?"

3 replies

Generally fill() should work; it focuses the element, clears any existing text, and types the text. Sometimes it doesn't work if there's special keyboard handling on the element though, in which case you should be able to use pressSequentially() https://playwright.dev/docs/api/class-locator#locator-press-sequentially

Note that if you use pressSequentially(), you might need to call blur() after if the focus needs to be removed from the locator for the event to be triggered

Thanks for the tip I’ll try that

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].