2016-08-30 15 views
2

我是新来的僵尸JS。我想填写登录字段并发布登录表单。我试图在zombiejs中编写这个代码,但得到错误。僵尸出现错误未处理的拒绝错误:超时:没有得到加载此页面上的所有资源

未处理拒绝错误:超时:没能加载所有资源 此页面上的超时(C:\用户\ sapna.maid \桌面\的NodeJS \首页\ node_modules \僵尸\ lib中 \ eventloop.js: 601:38) 在Timer.listOnTimeout(timers.js:92:15)

我的代码片段如下:

var zombie = require("zombie"); 
zombie.waitDuration = '30s'; 
//Browser.waitDuration = '300s'; 
var assert = require("assert"); 

browser = new zombie({ 
    maxWait: 10000, 
    waitDuration: 30*1000, 
    silent: true 
}); 
browser.visit("https://example.com", function() { 
    // fill search query field with value "zombie" 
    console.log("LOADEDDDD !!!!", browser.location.href); 
    console.log(this.browser.text('title')); 
    assert.equal(this.browser.text('title'), 'Welcome - Sign In'); 
    browser.fill('#user', '[email protected]'); 
    browser.fill('#pass', '[email protected]'); 

    browser.document.forms[0].submit(); 


    console.log(browser.text('title')); 
    // wait for new page to be loaded then fire callback function 
    browser.wait(5000).then(function() { 
    // just dump some debug data to see if we're on the right page 
    console.log(this.browser.success); 
    assert.ok(this.browser.success); 
    console.log("Browser title:: --------- " + this.browser.text('title')); 
    assert.equal(this.browser.text('title'), 'Dashboard'); 
    }) 
}); 

请帮我解决这个问题。 我在这里呆了很长时间。 在此先感谢!

回答

0

的第一个问题是,由于www.example.com的标题是Example Domain断言下面失败不Welcome - Sign In

assert.equal(this.browser.text('title'), 'Welcome - Sign In'); 

而且,这些线路将最有可能也会失败,因为有与页面上这样的id没有任何元素。

browser.fill('#user', '[email protected]'); 
browser.fill('#pass', '[email protected]'); 
+0

嗨mic4ael, 感谢您的回复。 我已经使用“www.example.com”为我的域的占位符。 我确信我的域名具有“#user”和“#pass”ids。 假设我的域名标题为“欢迎 - 登录”并且给定的ID有效,请帮我解决上述问题。 –

+0

是你公开的域名吗? – mic4ael

+0

是的。它可用。我可以点击链接,但无法提交登录请求/提交表单。 我推荐了一些博客,但无法解决问题。以下是该问题的一个网址。 https://github.com/assaf/zombie/issues/882 –

相关问题