2014-09-29 44 views
0

問題是我該如何做一個循環,我怎麼能有一個很好的結果,如 94 Url是好的,這三個不工作。環路網址和一個不錯的結果

var urls = [ 
'http://www.testify/page1', 
'http://www.testify/page2' 
]; 

module.exports = { 
'validate some url': function (test) { 
    test.open('http://www.testify/page1') 
     .wait(500) 
     .assert.title().is.not('Die Seite wurde leider nicht gefunden') 
     .assert.url('http://www.testify/page1', 'URL is as expected') 
     .assert.numberOfElements('.product').is.gt(0, 'There are more than 0 products') 
     .done(); 
}, 
}; 
+1

解決的辦法是;) http://www.snip2code.com/Snippet/23817/截圖-的-陣列-的-URLs-一個(DalekJS) – 2014-09-30 15:08:16

回答

0
module.exports = { 

    'A lot of screenshots': function (test) { 
    var resolutions = [{width: 1280, height: 1024}, {width: 1024, height: 768}, {width: 800, height: 600}]; 
    var pages = ['http://facebook.com', 'http://twitter.com', 'http://dalekjs.com']; 

    resolutions.forEach(function (res) { 
     pages.forEach(function (page) { 
      test.open(page) 
       .resize(res) 
       .screenshot('pics/' + res.width + '_' + res.height + '_' + page.replace('http://', '') + '.png') 
     }); 
    }); 

    test.done(); 
} 
} 
1

很高興地看到,你發現了這個問題的答案你自己。 萬一有人就這個問題再次跌倒,這將是需要爲您的初始代碼段代碼:

var urls = [ 
'http://www.testify/page1', 
'http://www.testify/page2' 
]; 

module.exports = { 
'validate some url': function (test) { 

    urls.forEach(function (url) { 
     test.open(url) 
      .wait(500) 
      .assert.title().is.not('Die Seite wurde leider nicht gefunden') 
      .assert.url(url, 'URL is as expected') 
      .assert.numberOfElements('.product').is.gt(0, 'There are more than 0 products') 
    }); 

    test.done(); 
    } 
}; 
相關問題