CasperJS测试从一些机器上失败,在其他机器上取得成功

时间:2015-04-14 09:16:52

标签: javascript node.js testing phantomjs casperjs

虽然CasperJS,PhantomJS,Node和NPM的版本都是相同的,但某些机器(OS X的所有不同版本)上的某些CasperJS测试失败并且没有其他版本会出现奇怪的问题。我错过了什么?代码的简化版本如下:

var userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:36.0) Gecko/20100101 Firefox/36.0',
    url = 'https://www.google.com/search?q=apple&ie=utf-8&oe=utf-8',
    selector = '#tads.c',
    timeoutMs = 10000;

casper.test.begin("test1", 1, function(test) {    
        casper.userAgent(userAgent);    
        casper.start(url)
        .waitForSelector(selector, function() {    
                test.assertExists(selector, 'selector: ' + selector);    
            }, function timeout() {    
                test.fail(selector + ' timed out after ' + timeoutMs + ' ms');    
            }, timeoutMs)    
        .run(function() {    
                test.done();
            });
    });

0 个答案:

没有答案