用剧作家填写条纹元素卡

Nik*_*des 2 stripe-payments playwright

我想使用 Playwright 填充条纹卡元素

常规定位器似乎不起作用。例如,以下示例不执行任何操作:

await page.fill('iframe input[name="cardnumber"]', '4242424242424242')
Run Code Online (Sandbox Code Playgroud)

如何使用 Playwright 填写卡输入信息(号码、CVC、有效期、邮政编码)?

Ret*_*Mac 7

这是使用 Playwright 的FrameLocator API实现此目的的最新方法,该 API 已添加到 v.1.17 中。

const stripeFrame = page.frameLocator('iframe').first();
await stripeFrame.locator('[placeholder="Card number"]').fill('4242424242424242');
await stripeFrame.locator('[placeholder="MM / YY"]').fill('04/30');
await stripeFrame.locator('[placeholder="CVC"]').fill('242');
Run Code Online (Sandbox Code Playgroud)