这是我第一次使用 puppeteer 进行测试。但我在运行时遇到了一个奇怪的错误
\n我想做的是在页面中运行这个函数,但是
\nconst 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)