菜单
开源

fill(value, [options])

使用提供的值填充 inputtextareacontenteditable 元素。

参数类型默认值描述
valuestring''要为 inputtextareacontenteditable 元素设置的值。
optionsobjectnull
options.forcebooleanfalse将其设置为 true 将绕过可操作性检查(visiblestableenabled)。
options.noWaitAfterbooleanfalse如果设置为 true 且执行此操作导致导航发生,则不会等待导航完成。
options.timeoutnumber30000最大时间(毫秒)。传递 0 禁用超时。默认值会被 BrowserContextPage 上的 setDefaultTimeout 选项覆盖。

返回值

类型描述
Promise<void>一个 Promise,在填充操作完成后兑现。

示例

JavaScript
import { browser } from 'k6/browser';

export const options = {
  scenarios: {
    browser: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
};

export default async function () {
  const page = await browser.newPage();
  await page.goto('https://test.k6.io/browser.php');
  const textbox = page.locator('#text1');
  await textbox.fill('hello world!');
}