【问题标题】:Loop for urls and a nice result循环网址和一个不错的结果
【发布时间】:2014-09-29 13:40:34
【问题描述】:

问题是我怎样才能做一个循环,我怎样才能有一个像这样的好结果 94 个网址都可以,这三个都不起作用。

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();
},
};

【问题讨论】:

标签: dalekjs


【解决方案1】:

很高兴看到您自己找到了该问题的答案。 如果有人再次偶然发现这个问题,这将是您的初始代码 sn-p 所需的代码:

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();
  }
};

【讨论】:

    【解决方案2】:
    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();
    }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-28
      • 2018-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多