html - Puppeteer 没有填写输入元素/错误的选择器?
问题描述
我试图让 puppeteer 自动填写信用卡流程。
await page.waitForSelector('#cardpan input[type = text]');
await page.waitForSelector('#cardexpiremonth input[type = text]"]');
await page.waitForSelector('#cardexpireyear input[type = text]');
await page.waitForSelector('#cardcvc2 input[type = text]');
await page.evaluate(() => {
const ccnumber = document.querySelector('#cardpan input[type = text]');
ccnumber.value = 'Here comes cc number';
const month = document.querySelector('#cardexpiremonth input[type = text]"]');
month.value = '...';
const year = document.querySelector('#cardexpireyear input[type = text]');
year.value = '...';
const cvc = document.querySelector('#cardcvc2 input[type = text]');
cvc.value = '...';
});
我还尝试了许多不同的其他方法来选择输入元素,但它没有填写该字段。提前感谢您的帮助!:)
解决方案
推荐阅读
- python - 日志消息在 Python 日志记录中出现两次:首先使用格式化程序,然后没有格式化程序
- javascript - 如何在 web3.js 上打印 solidity revert me 消息?
- javascript - 将字符串从 javascript 中的变量添加到 HTML 中的 API URL
- flutter - Flutter HiveDB 从数据库中删除
- visual-studio-code - 你如何在vscode(mac)中显示顶部菜单栏
- mysql - 在一年内找到第一笔订单
- python - 如何从 url 读取数据到 pandas 数据框
- load-balancing - 意味着在更改证书的 LB 后面正确验证 NIFI 用户?
- javascript - 未捕获的类型错误:无法读取未定义的属性(读取“attribute_value”)
- db2 - DB2 Z/OS - 重新验证 UDF 和存储过程