小编sar*_*isa的帖子

Puppeteer - 删除由exposeFunction 公开的函数?

我以下列方式使用exposeFunction-command:

await this.page.exposeFunction('foo', function(){ return 'bar'; });
Run Code Online (Sandbox Code Playgroud)

这按预期工作,并为我提供了 window.foo 函数。

如果我再次调用此代码,则会出现以下错误:

Error: Failed to add page binding with name foo: window['foo'] already exists!
Run Code Online (Sandbox Code Playgroud)

使用 page.goto() 导航时,此错误甚至仍然存在。

有没有办法解除exposeFunction()公开的函数的绑定?

javascript webautomation node.js puppeteer

6
推荐指数
1
解决办法
635
查看次数

标签 统计

javascript ×1

node.js ×1

puppeteer ×1

webautomation ×1