我以下列方式使用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()公开的函数的绑定?