screen-pill
v1.1.7
Published
Page Object pattern in javascript
Downloads
14
Maintainers
Readme
screen-pill
library for creating page objects in javascript
inpsired by cheezy's ruby implementation
check out the cucumber demo
install
npm install screen-pill
usage
declare a function to encapsulate a web page
// google-search.js
const ScreenPill = require('screen-pill')
function GoogleSearch(driver) {
this.setDriver(driver)
this.directUrl('http://www.google.com')
this.textField('terms', {name: 'q'})
this.submit('google')
this.submit('feelingLucky', {index: 1})
this.query = async function(query) {
await this.terms.waitUntilPresent()
await this.terms.set(query)
await this.google.waitUntilPresent()
return this.google.click()
}
return this
}
module.exports = ScreenPill(GoogleSearch)
instantiate with driver and use methods
const webdriver = require('selenium-webdriver')
const driver = new webdriver.Builder().forBrowser('chrome').build()
const GoogleSearch = require('google-search')
let searchPage = new GoogleSearch(driver)
async function search() {
await searchPage.visit()
return searchPage.query('cats')
}
search()
documentation
see /test
for examples using cucumber and chai
see wiki for api and usage
under active development (contributions welcome)
contributors
- sean gregory
- phil jordan
special thanks
- jesse keane