LearnBoost / soda

Selenium Node.JS adapter
http://labs.learnboost.com
464 stars 43 forks source link

Can't make screenshots of failed qunit tests #61

Open fbuchinger opened 11 years ago

fbuchinger commented 11 years ago

I want to run our qunit tests in different browsers using selenium/soda and capture screenshots of failed tests.

function runTestsInBrowser(browserName){
    var browser = soda.createClient({
        host: 'localhost'
      , port: 4444
      , url: 'http://localhost'
      , browser: browserName
    });

   browser
  .chain
  .session()
  .open('/testpage.html')
  .waitForTextPresent('Tests completed')
  .assertTextPresent('0 failed')
  .end(function(err){
    browser.testComplete(function(){
      console.log('done');
      if (err){
        var timestamp = (new Date).toISOString().split(':').join('-').split('.')[0];
        browser.captureEntirePageScreenshot('D:\\dev\\selenium\\screenshots\\' + browserName + '_' + timestamp + '.png');
        //throw err;
      } 
    });
  });
}

runTestsInBrowser('firefoxchrome');
//runTestsInBrowser('iexplore');
runTestsInBrowser('chrome');

unfortunately, this leads to an exception:

D:\dev\selenium\soda\lib\soda\client.js:122
        fn(new Error(err), res.body, res);
        ^
TypeError: string is not a function
    at IncomingMessage.<anonymous> (D:\dev\selenium\soda\lib\soda\client.js:122:
9)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

turns out that the screenshot file path was assigned to fn. am i doing something wrong?