node.js - Puppeteer page.evalute 找不到块范围变量
问题描述
function clickElement(page, selector, textTarget) {
page.evaluate(() => {
[...document.querySelectorAll(selector)]
.find((element) => element.textContent === textTarget)
.click();
console.log(selector,textTarget)
// selector and textTarget is undefined
});
}
在此示例中,page.evaluate 无法访问块范围变量、选择器和 textTarget。
解决方案
推荐阅读
- python - 如何将列表循环到 loc、isin 和 sum 函数中
- blueprism - 当我们从 BluePrism 工具调用 http 请求时,未将对象引用设置为对象的实例
- python - 查找列表中第 k 个最大的元素
- entity-framework - 具有不同名称的实体框架查询表
- postgresql - 如何修复konga_db
- angular - 如何为多个按钮创建 Angular 2+ 切换?
- python - 如何从列表中选择一个随机值?
- google-bigquery - Talend BigQuery - SQL
- python-3.x - 如何修复 Colaboratory 中的 zipfile 读取错误?
- android - 无法使用 com.android.billingclient:billing 获取 SkuDetail