Zombie.js with Behat and Mink

Zombie.js with Behat and Mink

本文关键字:and Mink Behat with js Zombie      更新时间:2023-09-26

我在让Behat使用Zombie.js方面遇到了一个又一个问题。我现在遇到的问题实际上是在Zombie.js模块中(以前,错误是在两者之间的链接中)。

错误看起来是这样的。

  [RuntimeException]                                                                                                                                   
  Server process has been terminated: (8) [                                                                                                            
  url.js:107                                                                                                                                           
      throw new TypeError("Parameter 'url' must be a string, not " + typeof url)                                                                       
            ^                                                                                                                                          
  TypeError: Parameter 'url' must be a string, not undefined                                                                                           
      at Url.parse (url.js:107:11)                                                                                                                     
      at urlParse (url.js:101:5)                                                                                                                       
      at Object.urlResolve [as resolve] (url.js:405:10)                                                                                                
      at History._resolve (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/history.coffee:201:20)                                         
      at History._assign (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/history.coffee:209:18)                                          
      at /Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:326:30                                                            
      at Browser.withOptions (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:105:14)                                      
      at Browser.visit (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:320:12)                                            
      at Socket.eval (eval at <anonymous> (/private/var/folders/fv/fp4xrfnx7kzfq2bqzywq5p9w00010f/T/mink_nodejs_serverSZBH0W:43:10), <anonymous>:2:9)  
      at Socket.<anonymous> (/private/var/folders/fv/fp4xrfnx7kzfq2bqzywq5p9w00010f/T/mink_nodejs_serverSZBH0W:43:5)                                   
  ]                                                                                                                                                    

我发现在history.coffee中,resolve函数试图使用一个不存在的数组元素。

  // history.coffee
  _resolve: (url)->
    if url
      return URL.resolve(@_stack[@_index]?.url, url)
    else # Yes, this could happen
  return @_stack[@_index]?.url

@_stack[@_index]的引用解析为未定义,然后将其传递到URL.resolve,从而导致错误。

知道为什么会发生这种事吗?

更新

我注意到@_stack是空的,而@_index-1。这不可能,对吧?

僵尸驱动程序与节点版本0.8.24断开(0.8.23工作正常)。我相信这是由于的变化

2013.06.04, Version 0.8.24 (maintenance), c1a1ab067721ea17ef7b05ec5c68b01321017f05
* url: Properly parse certain oddly formed urls (isaacs)

0.10.10中似乎也进行了类似的更改(在同一天进行)(尽管我没有直接研究提交)。

2013.06.04, Version 0.10.10 (Stable), 25e51c396aa23018603baae2b1d9390f5d9db496
* url: Properly parse certain oddly formed urls (isaacs)

我建议恢复到0.8.23或0.10.9以使其工作。如果你还没有使用它,我建议nvm来管理你的节点安装。

尝试使用Mink/Behat/Symfony2.1 模拟$nodeElement->mouseOver()时出现相同问题

TypeError: Parameter 'url' must be a string, not object
    at Url.parse (url.js:107:11)
    at urlParse (url.js:101:5)
    at Object.urlResolve [as resolve] (url.js:405:10)
    at Object.iframe.setAttribute (/usr/lib/node_modules/zombie/lib/zombie/jsdom_patches.js:164:43)
    at attrCopy (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:331:14)
    at Object.core.Node.cloneNode (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:636:18)
    at Object.core.Node.cloneNode (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:706:37)
    at Function.jQuery.extend.clone (/js/2225e47_jquery-1.8.2_2.js:6222:17)
    at Function.jQuery.extend.parseHTML (/js/2225e47_jquery-1.8.2_2.js:501:31)
    at jQuery.fn.jQuery.init (/js/2225e47_jquery-1.8.2_2.js:131:24)
    at jQuery (/js/2225e47_jquery-1.8.2_2.js:44:10)
    in /js/45a7194_jquery.jqModal_9.js

节点版本为v0.10.15。仍在寻找答案。