Astrolabe
Astrolabe
is an extension for protractor that adds page objects to your functional/e2e tests.
Installation
via npm (node package manager)
$ npm install astrolabe
Usage
Example signInPage.js
var Page = Page;moduleexports = Page;
adding to tests:
var signInPage = ;...
navigating:
signInPage; // will send browser to 'http://mysite.com/signin'signInPage; // will send browser to 'http://mysite.com/signin/some/path'signInPage; // will send browser to 'http://mysite.com/signin/some/path'signInPage; // will send browser to 'http://mysite.com/signin?some=query'
interacting: (See Protractor API Docs for more info on available api methods)
signInPageusername; // will fill the username input with the text 'a username'signInPagesubmit; // will click on the submit element
signInPageusername; // will return a promise that is resolved with the value of the text field, in this case 'a username'// this can be used within an expectation;
It is possible to create convenience methods to wrap up common logic.
Example signInPage.js
var Page = Page;moduleexports = Page;
can be used in your tests:
var signInPage = ;...signInPage; // will navigate to sign in page, enter username and password then click submit....
Cloning and running Astrolabe's tests
Clone the github repository.
git clone https://github.com/stuplum/astrolabe.git
cd astrolabe
npm install
npm test
Running Astrolabe's example protractor test
Install protractor with.
npm install protractor
Start up a selenium server (See the appendix below for help with this). By default, the tests expect the selenium server to be running at http://localhost:4444/wd/hub
.
The example folder contains a simple test suite which runs against angularjs.org. It is a port of the simple test suite included with protractor.
Currently only the protractor runner is supported. The runner accepts a configuration file, which runs the tests at example/onProtractorRunner.js
.
node_modules/.bin/protractor examples/protractor.conf.js
Setting up a standalone selenium server
See Appendix A of protractor's installation instructions