剧作家未能填写输入

Playwright fails to fill input

我是 运行 Jenkins 页面上的编剧脚本,该页面具有输入元素。当我尝试 fill 其中一个带有文本的输入时,它失败并出现此错误:

(node:3337) UnhandledPromiseRejectionWarning: page.fill: Protocol error (Page.insertText): error in channel "content::page": exception while running method "insertText" in namespace "page": Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsITextInputProcessor.commitCompositionWith] _insertText@chrome://juggler/content/content/PageAgent.js:891:32

我试过 运行 DEBUG=pw:api environment 启用,但那里的日志没有太大帮助。从正常的控制台日志中,我得到以下日志:

waiting for selector "input[name="_.buildNumber"]"
  selector resolved to visible <input value="" type="text" name="_.buildNumber" class=…/>
elementHandle.fill("54")
  waiting for element to be visible, enabled and editable
  element is visible, enabled and editable

所以看起来该元素存在并且可以编辑,但出于某种原因,Playwright 未能成功尝试填充它。我在这里错过了什么?

这是 Firefox 特有的 Playwright bug。为了暂时解决这个问题,您应该能够在 import 语句中切换到使用 Chrome 或 Safari。所以要么:

import { chromium } from 'playwright';

或使用 Safari:

import { webkit } from 'playwright';