MarketSquare / MarketSquare/robotframework-browser

Add `Set Page Content` keyword to set the page HTML directly

Open
#5,116 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Use case

Sometimes a test needs a page with exact, known HTML — component or snippet testing, reproducing a rendering bug, or exercising a keyword against a minimal DOM — without standing up a web server or writing a temporary file and navigating to a file:// URL (the current clumsy workaround). Playwright supports this directly with page.setContent, but the library does not expose it.

Proposed keyword / arguments

Set Page Content html *, wait_until=load timeout=None

  • html — the HTML markup to assign to the page (replaces the whole document).
  • wait_until — load state to wait for, same enum as Go To / Reload (load, domcontentloaded, networkidle, commit); default load.
  • timeout — maximum wait time (Robot Framework time format); falls back to the library timeout when omitted.
New Page
Set Page Content    <h1>Hello</h1><button id="go" onclick="this.textContent='clicked'">Go</button>
Get Text    h1    ==    Hello
Click    id=go
Get Text    id=go    ==    clicked

Set Page Content    ${LONG_SNIPPET}    wait_until=domcontentloaded    timeout=5s

Playwright API

page.setContent

Implementation notes

  • New RPC in protobuf/playwright.proto (html, waitUntil, timeout).
  • Trivial pass-through in node/playwright-wrapper on the active page.
  • Python keyword (fits Browser/keywords/playwright_state.py or the getters/content module), docs, atest with a subsequent interaction/assertion on the injected content.

Backwards compatibility

Purely additive: a new keyword; no changes to existing keywords.

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.

Research direction

Start with the related Go To and Reload RPC definitions in protobuf/playwright.proto, then inspect node/playwright-wrapper and the Python keyword modules suggested in the issue. Add an atest that injects HTML and performs a subsequent interaction and assertion, update the documentation, and verify wait_until and timeout behavior against the described Playwright API.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, python
Domain
api, testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.