Zombiejs browser.text方法返回整个文档

时间:2012-02-19 16:11:15

标签: node.js zombie.js

就像它在标题中所说:

zombie = require "zombie"
should = require "should"
browser = new zombie.Browser();

describe "index", ->
  describe "herp derp", ->
    it "should display room input", (done) ->
      browser.visit "http://localhost:3000/", (err, browser) ->
        if err
          throw err.message
        browser.text('title').should.equal 'Welcome to Test!'
        done()

browser.text(' title')返回整个页面的html。我尝试选择的任何元素都会发生这种情况。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

如果您将代码更改为此,会发生什么:

Browser = require "zombie"
should = require "should"


describe "index", ->
  describe "herp derp", ->
    it "should display room input", (done) ->
      Browser.visit "http://localhost:3000/", (err, browser) ->
        if err
          throw err.message
        browser.text('title').should.equal 'Welcome to Test!'
        done()