检查 DOM 元素的 Node.js 模块
我正在使用 zombie.js,一个主要用于测试目的的无头浏览器。它创建一个浏览器对象,一旦调用函数 visit()
,您就可以使用给定页面的 DOM。然而,我没能达到那个程度。看起来僵尸中使用的解析器有问题。 这是错误:
User/murf/Documents/workspace/node_code/node_modules/zombie/node_modules/html5/lib/html5/tokenizer.js:62
有人发现类似的问题吗?如果是这样,有没有办法绕过它?或者也许还有另一个节点模块可以完成类似的工作?任何想法都将不胜感激。
谢谢
I'm using zombie.js, a headless browser mostly for testing purposes. It creates a browser object that once the function visit()
is called allows you to play with the DOM of a given page. However, I wasn't able to get it to that extent. It looks like there is an issue with the parser used in zombie.
Here is the error:
User/murf/Documents/workspace/node_code/node_modules/zombie/node_modules/html5/lib/html5/tokenizer.js:62
Has anyone found a similar issue? If so, is there a way to go around it? Or maybe is there is another node module that does similar work? Any idea is greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ZombieJS 和其他 Web 测试工具构建在 JSDOM 之上,就像 Zombie 一样非常易于使用。然而,问题是你没有像“类型”这样的东西,但你可以很容易地在 JSDOM 中模拟它,例如:
这是 JSDOM 的代码示例,所以如果你想要模拟类型,你就必须触发手动
keydown
这将以某种方式模拟
type('x')
,例如。对于将触发获取建议框的谷歌搜索。但是,为了正确模拟它,您必须使用 keyCode 和所有内容创建一个 keydown 事件。
我正在为 Node 开发一个新的无头浏览器,名为 htmlnode,但它仍在进行中,预计下周即可使用,它构建在 HtmlUnit 之上。
其他选项:
ZombieJS and other web testing tools is built on JSDOM which is really easy to use just like Zombie. However the thing is you don't have stuff like "type" but you could easily simulate it in JSDOM, example:
That is a code sample from JSDOM, so if you want for example to simulate type you'll have to trigger for instance
keydown
manuallyThat will somehow simulate
type('x')
, for ex. for google search that will trigger getting the suggestion box.However in order to properly simulate it, you have to create a keydown event with keyCode and everything.
I'm working on a new headless browser for Node called htmlnode, but its still work in progress, expected to be usable next week, and its built on top of HtmlUnit.
Other options: