pagerun
v0.9.11
Published
WebPage runner
Downloads
36
Maintainers
Readme
pageRun
pageRun is a webpage runner, used for webpage analysis.
It support a lot of plugins, you can also develop your own plugin upload to npm.
Features
- Support http & https.
- Support much of browsers with webdriver, such as: ie, chrome, firefox, android, ios.
- Powerful plugin system on npm.
- Easy to develop plugin.
- Easy to use.
Install
Install Nodejs
Install OpenSSL
Download webdriver.
http://code.google.com/p/selenium/downloads/list
Chrome & ie must download chromeDriver & IEDriverServer.
Tip: Add the directory to PATH, so you can use it.
Install pagerun from npm
npm install pagerun
Install plugins from npm
npm install pagerun-httpsummary npm install pagerun-httperror npm install pagerun-jserror npm install pagerun-pagesummary npm install pagerun-jsunit npm install pagerun-htmlhint
Usage
Run selenium server
java -jar selenium-server-standalone-2.41.0.jar
Run pagerun
var pagerun = require('pagerun'); pagerun.loadNpmPlugin('httpsummary'); pagerun.loadNpmPlugin('httperror'); pagerun.loadNpmPlugin('jserror'); pagerun.loadNpmPlugin('pagesummary'); pagerun.loadNpmPlugin('jsunit'); pagerun.loadNpmPlugin('htmlhint'); pagerun.setConfig({ pageproxy: { keyPath: "./cert/" }, webdriver: { browserName: 'chrome', browserVersion: '', url: 'http://www.baidu.com/', loginUrl: '', loginPreClick: '', loginParams: { 'username': 'xxx', 'password': 'xxx' }, loginButton: 'doLogin', scrollToEnd: true, screenshot: false }, hosts: 'www.alibaba.com www.baidu.com', htmlhint: { "doctype-first": true, "spec-char-escape": true, "tag-pair": true, "id-unique": true, "src-not-empty": true, } }); pagerun.mode = 'test'; pagerun.run(function(result){ console.log(result.success); console.log(JSON.stringify(result.messages,null,4)); // console.log(result.logs); process.exit(0); });
API
pagerun.loadNpmPlugin(pluginName)
Load plugin from npm.
Npm plugin name must match: pagerun-xxx (pluginName == xxx)
pagerun.setConfig(configs)
Set config for all plugins.
pagerun.mode
Set run mode:
product: default mode, no log output.
test: show logs
debug: show logs and stop run after webdriver open url.
pagerun.modulesRoot
Set default modules root, default: ./node_modules/
This propertie can used for npm plugin develop.
pagerun.run(callback)
Start pagerun task.
The first argument is the task callback. It will set result object to the callback:
- result.success: true(success), false(failed)
- result.messages: task results
- result.logs: task logs
Core plugins
All core plugins will loaded with pagerun task.
The plugin is used for read and edit http request.
The plugin is used for Change hosts.
Control webdriver to open target url.
Inject code to webpage.
Set pagerun object to browser.
So you can use pagerun.error('jserror', {'text':'abc'}) in browser.
Npm plugins
All npm plugins can loaded by pagerun.loadNpmPlugin api.
Catch all http error such as:4xx, 5xx.
Lint html content with HtmlHint.
Save all http response content, so you can analyze the http content after run.
Save http summary for pagerun.
Get page summary in webpage, such as: dom time, dom count.
Catch onerror info.
Catch js unit test result, supoort: Mocha, Jasmine, QUnit, YUI Test.
Get coverage info after js run.
License
paegRun is released under the MIT license:
The MIT License
Copyright (c) 2014 Yanis Wang < [email protected] >
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Thanks
- GitHub: https://github.com/