2016-08-30 11 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 –

相關問題