screen-pill

1.1.7 • Public • Published

screen-pill Build Status GitHub Coverage Status Dependencies

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

Package Sidebar

Install

npm i screen-pill

Weekly Downloads

0

Version

1.1.7

License

MIT

Unpacked Size

84 kB

Total Files

28

Last publish

Collaborators

  • skinnyjames