Using jQuery in Zombie.js

佐手、 提交于 2019-12-05 06:55:58

If your site is already loading jquery, you can use the loaded jQuery straight away, which in some cases is far easier.

var document = browser.window.$("body");

Will work as expected, since it is a jQuery object.

I think that you can add script files anyway so you could dinamically add jQuery and use it as I just mentioned.

Hope this helps!

If the page you are working with doesn't include jQuery, and you are only retrieving data, then try using Cheerio on top of Zombie:

zombie.visit("http://example.com", function () {
  var $ = cheerio.load(browser.html());
  console.log($('title').text());
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!