[英]How can I test JavaScript output in the DOM without a browser?
I would like to test the output generated by some functions which are responsible to generate new content in the dom. 我想测试由某些函数生成的输出,这些函数负责在dom中生成新内容。 The problem is that I need to test such scenarios without using a browser and by running xpath queries against the generated output. 问题是,我需要在不使用浏览器的情况下,通过对生成的输出运行xpath查询来测试这种情况。 (something like HTMLUnit in Java). (类似于Java中的HTMLUnit)。 How can I write such tests? 我该如何编写此类测试? Which framework/technology can I use? 我可以使用哪种框架/技术?
This is usually handled by using a browser running on a fake screen (eg using xvfb ) and driving it programmatically. 通常通过使用在假屏幕上运行的浏览器(例如,使用xvfb )并以编程方式驱动它来处理。 Headless will let you set up xvfb from within node.js. Headless将让您从node.js内设置xvfb。
Phantom and Selenium provide a couple of ways to drive browsers. Phantom和Selenium提供了两种驱动浏览器的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.