小编Lev*_*per的帖子

错误:评估失败:无效参数:应该恰好是一个字符串。| Puppeteer .evaluate() 错误

这是我第一次使用 puppeteer 进行测试。但我在运行时遇到了一个奇怪的错误

\n

我想做的是在页面中运行这个函数,但是

\n
const puppeteer = require('puppeteer');   \nlet browser, page,\n//evaluates to file://C:/Users/chris/Google Drive/code projects/text translation sheet/test/src/index.html\n    htmlFilepath = "file://" + path.resolve(__dirname, "src/index.html");\nbrowser = await puppeteer.launch();\npage = await browser.newPage();\nawait page.goto(htmlFilepath);   \npage.exposeFunction(getMaxWordsInContentArea.name, getMaxWordsInContentArea)\n      \nconst lastWordThatFit = await page.evaluate(function(){\n          \n    const el = document.querySelector('.line__target-language-text')\n    const elContainer = el.parent;\n    const lastFitWordIndex = getMaxWordsInContentArea(el,elContainer,["Call", "me", "Ishmael.", "Some", "years", "ago\xe2\x80\x94never", "mind", "how", "long", "precisely\xe2\x80\x94having", "little", "or", "no", "money", "in", "my", "purse,", "and", "nothing", "particular", "to", "interest", "me", "on", "shore,", "I", "thought", "I", "would", …
Run Code Online (Sandbox Code Playgroud)

javascript puppeteer

4
推荐指数
1
解决办法
755
查看次数

标签 统计

javascript ×1

puppeteer ×1