Skip to content

[BUG] page.type() can’t type inside an Electron <webview> #9729

Open
@andersk

Description

@andersk

Context:

  • Playwright Version: 1.16.1
  • Operating System: Linux
  • Node.js version: 14.18.0
  • Browser: Electron 15.3.0

Code Snippet

// index.js
const { app, BrowserWindow } = require("electron");

app.whenReady().then(() => {
  const win = new BrowserWindow({
    webPreferences: { webviewTag: true },
  });
  win.loadFile("index.html");
});
app.on("window-all-closed", () => {
  app.quit();
});
<!-- index.html -->
<title>Test app</title>
<webview src="textarea.html"></webview>
<!-- textarea.html -->
<title>Text area</title>
<textarea id="text">initial text</textarea>
// test.js
const { _electron } = require("playwright-core");

(async () => {
  const app = await _electron.launch({ args: ["."] });
  const page = await app.waitForEvent("window");
  console.log("title =", await page.title());
  await page.type("#text", "NEW TEXT ");
  await page.waitForTimeout(1000);
  console.log("value =", await page.inputValue("#text"));
  await app.close();
})();

Describe the bug

When I try to use page.type() to type into a <textarea> inside an Electron <webview>, the <textarea> is focused, but no characters are added to it.

$ npm i electron playwright-core
$ node test.js
title = Text area
value = initial text

(Expected value = NEW TEXT initial text.)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions