2013-05-30 101 views
0

提交表单我使用的浏览器模块(https://github.com/shinout/browser)来测试node.js的表单提交,它是通过运行下面的代码成功:模块在node.js中

var $b = new browser(); 
$b.submit({ 
    from : 'https://accounts.google.com/Login', 
    selector: "#gaia_loginform", 
    data : { 
    Email : "[email protected]", 
    Passwd : "XXXXXXXX" 
    } 
}); 

// authenticated access 
$b.browse('https://mail.google.com/mail/u/0/?ui=html&zy=d') 
.after(); // browse after previously registered function 

$b.on("end", function(err, out) { 
    console.log(out.url, out.result, out.responseHeaders); 
}); 

$b.run(); 

但是当我添加

Junjo.register cannot be called when the template is frozen. 

我不硝酸钾:$ b.run()

$b.browse('https://mail.google.com').after(); 
$b.run(); 

我得到了下面的错误后附加代码为什么。任何帮助,将不胜感激。

回答

0

从我能够从源文件中读取的内容来看,浏览器模块不支持使用单个浏览器实例运行多个作业。方法$b.run()将对象标记为冻结,这会导致像browse这样的方法抛出您收到的错误。

+0

第一个$ b.run()存储我想要的$ b中的cookie。如果我想稍后使用cookie,我应该怎么做?谢谢。 –

+0

我可以调用$ b.run()后再次调用$ b.run()吗?等待你的帮助。谢谢。 –

+0

为什么不尝试再次自己调用$ b.run()?但似乎第一个电话设置了一个标志,第二个电话什么都不做。我以为你会想重用cookie,但我没有找到一个方法如何做到这一点:(为什么不写一封电子邮件给浏览器模块的作者?https://github.com/shinout –