是否可以从 HTML 字符串创建页面,就像使用 jsdom 一样,如下所示:
global.document = jsdom.jsdom('<!doctype html><html><body></body></html>');
而不是使用 goto
方法。
最佳答案
如果您愿意写入中间文件,Nightmare 确实支持 file://
URI。例如:
nightmare.goto('file:///some/location/on/disk/myfile.html')
.then( ... )
Nightmare 不支持开箱即用的直接 HTML 注入(inject)。
关于javascript - NightmareJS 从字符串创建页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40653722/