LearnBoost / soda

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

http status code of page? #37

Closed quangv closed 12 years ago

quangv commented 12 years ago

Is there anyway to get the statusCode of the current page?

I thought that you could do something like this

var client = require('soda').createClient({
  host: 'localhost',
  port: 4444,
  url: 'http://return500',
  browser: 'firefox'
});

client
.chain
.session()
.open('http://return500', function(body, res) {
  assert.equal(500, res.statusCode);
})
.end();

but alas, res.statusCode seems to be between the client and Selenium server (i think?)... not the HTTP returned from the actual browser page...

any help would be appreciated.

(note, soda might not even return this information, if anyone knows if it's a definitive no, please let me know, and I'll stop searching...) Thanks! :)

quangv commented 12 years ago

Can this be achieved using captureNetworkTraffic? I could never get the included example to work

browser
        .chain
        .session()
        .open('http://www.pcmag.com')
        .waitForPageToLoad()
        /* 'json|xml|txt' */
        .captureNetworkTraffic('json', function(traffic) {
            fs.writeFile('traffic.json', traffic);
        })
        .testComplete()
        .end(function(error) {
        });

just wanted to add, http status codes is currently not accessible through selenium http://code.google.com/p/selenium/issues/detail?id=141 but perhaps there's a way to do with easily with Soda?

quangv commented 12 years ago

I decided to use superAgent instead to check for http status codes.