MarketSquare / MarketSquare/robotframework-browser

Add `Blur` keyword to remove focus from an element

Open
#5,102 0 comments 0 reactions 1 assignee View on GitHub

@Snooz82 is already working on this.

Since Aug 6, 2026.

enhancement
Dominant language
Python
Stars
655
Forks
147
Avg merge
5h 27m
Merged PRs (30d)
59

Description

## Use case

Many forms run their validation, formatting or `onchange` logic only when a field **loses** focus. After `Fill Text` the field typically still has focus, so that logic never fires and assertions on validation messages fail. The library has a `Focus` keyword but no counterpart to remove focus; today users must fall back to `Evaluate JavaScript selector (e) => e.blur()`, which bypasses Playwright's auto-waiting and strict-mode selector resolution. Playwright provides `locator.blur` for exactly this.

## Proposed keyword / arguments

`Blur selector *, timeout=None`

- `selector` — element to blur (auto-waits, strict-mode resolved, supports `->>` frame piercing like `Focus`).
- `timeout` — maximum wait time for the element; library timeout when omitted.

```robotframework
Fill Text id=email not-an-email
Blur id=email
Get Text css=.validation-error == Please enter a valid email address

Focus id=search
Blur id=search
Get Element States id=search not contains focused
```

## Playwright API

[`locator.blur`](https://playwright.dev/docs/api/class-locator#locator-blur)

## Implementation notes

- New RPC in `protobuf/playwright.proto` (selector, strict, timeout) — or reuse of the generic selector-action request shape used by `Focus`.
- One-line locator call in `node/playwright-wrapper/interaction`.
- Python keyword next to `focus` in `Browser/keywords/interaction.py`, docs, atest verifying a blur-triggered `onchange` handler fires.

## Backwards compatibility

Purely additive: a new keyword complementing the existing `Focus`; no existing behavior changes.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.