selenium - How to test a website -
i've been looking ways perform basic automated tests:
- does given page have expected http status (typically 200)
- are there problems related files (http status on used files such js, css, images, fonts, ...)
- are there js errors while loading page
many of commonly used tools (such selenium) don't seem support these tests, don't know start... know simple solution covering these tests ?
we have succeeded in setting unit testing using mocha.
website: http://visionmedia.github.io/mocha/
problem 1: checking http status
i found alternative this: superagent https://github.com/visionmedia/superagent
this module allows perform basic http requests , gives information might expect. can use check kind of header (ie. check if you're getting json data when set "accept-type: application/json" in request)
request .get('http://mywebsite/') .end(function (res) { assert.strictequal(res.statuscode, 200); done(); });
problem 2: checking missing files
no working solution yet, we're looking node.js crawlers done: https://nodejsmodules.org/tags/crawling
problem 3: checking javascript errors
we use generic error handler (window.onerror) store js errors in global variable. webdriverjs (selenium client written in node.js) allows inject js retrieve information. our code:
client .execute("return typeof window.errors", [], function (err, output) { assert.isnull(err); assert.strictequal(output.value, "undefined"); }) .call(done);
Comments
Post a Comment