Selenium Page Object Generator
A nimble and flexible Selenium Page Object Model generator to improve agile testing process velocity.
Selenium Page Object Generator is an essential tool to improve your workflow. It will generate Page Object Model on active Chrome or Opera tab with a single click, provided that all of the options and template are configured. The generated Page Object Model will be saved to pre-configured Chrome or Opera download folder.
Selenium Page Object Generator is also available in command line by installing Node.JS package from NPM Registry.
The template is using Handlebars.js expression, a clean logic-less semantic templating language.
This is an early BETA release, it expected to have rough edges, and limited functionality. It currently support 3 different targets: Java, C#, and Robot Framework.
For more information on how to use the generated Page Object file:
Java: https://code.google.com/p/selenium/wiki/PageFactory#The
C#: http://relevantcodes.com/pageobjects-and-pagefactory-design-patterns-in-selenium/#post-5229
Robot Framework: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#taking-resource-files-into-use
(You need to use Chrome 40+ or Opera 15+ or Node.JS 5.x to try this out)
Installation
- To install the newest released version on Chrome browser, please download it from Chrome web store.
- To install the newest released version on Opera browser, please download it from Opera addons catalog.
- To install the newest released version on command line, please install Node.js and run command below:
$ npm install selenium-page-object-generator
Command Line Usage
Selenium Page Object Generator accepts the following command line arguments:
selenium-page-object-generator [options]
-h, --help Show this help message and exit.
-v, --version Show program's version number and exit.
-t, --target {cs,java,robot} Generator target
-n, --name [PageName] Page name (no-spaces)
-d, --destination [DestinationPageName] Destination page name (no-spaces) (optional)
-s, --source [source.html] Source file
Examples
To generate Java page object:
$ node_modules/.bin/selenium-page-object-generator -t java -n MySite -s source.html
Development Dependencies
You will need to install Node.js as a local development dependency. The npm
package manager comes bundled with all recent releases of Node.js
.
npm install
will attempt to resolve any npm
module dependencies that have been declared in the projectโs package.json
file, installing them into the node_modules
folder.
$ npm install
Development
To build the sources into corresponding packages, run:
$ npm run build
The /build
folder and /dist
folder are created. All built files are placed in the build
folder, and the distribution ready packages are placed in dist
folder.
Run Unit Tests
To make sure we did not break anything, let's run:
$ npm test
Distribution
Once the changes are in-place and ready for distribution, update package.json
with new version, and run:
$ npm run build
The /dist
folder will contain distribution ready packages.
Contributing
If you would like to contribute code to Selenium Page Object Generator project you can do so through GitHub by forking the repository and sending a pull request.
When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Please also include appropriate test cases.
Before your code can be accepted into the project you must also sign the Selenium Page Object Generator CLA (Individual Contributor License Agreement).
That's it! Thank you for your contribution!
License
Copyright (c) 2015, 2016, 2018 Richard Huang.
This browser extension is free software, licensed under: GNU Affero General Public License (AGPL-3.0).
Documentation and other similar content are provided under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Licenses and Acknowledgements for Incorporated Software
- Handlebars is an open source software provided under MIT license.
- jQuery is an open source software provided under MIT license.