Tamarin
Tamarin allows the tester/developer to concentrate on the functionality that needs to be tested rather than the boiler-plate code around it in order for the test to work.
I have often asked myself As a user would I ever click on an invisible link, type in a disabled field or select an item from a dynamically loaded dropdown that hadn't loaded yet? My answer was of course I wouldn't! so why do we have to write tests to make sure this doesn't happen? What if all that extra code was abstracted away and all you had to do was implement a one-line "click" and everything else was taken care of?
Tamarin can be used with or without cucumber.js.
Note the following files taken from the example project: tamarin-vanilla-example.
index.js
const googleSearch = googleSearch
google_search.js
const World = Worldconst world = const page = 'search': css: '[title="Search"]' 'navLink': xpath: '//*[@role="navigation"]//a[text()="Images"]' 'results': css: 'img[alt="Image result for Tamarin"]' moduleexports = world world
world.js
'use strict' const driver = const tamarin = moduleexports = World: { super } { return this }
driver.js
'use strict' const webDriver = const chrome = const service = pathchrome module { return }
Under the hood, tamarin waits until an element exists, is visible and enabled prior to performing such actions such as clicking a button or keying text into an input field.
API
tamarin contains the following functions within the tamarin world object:
- setData (key, val)
- getData (key) .. returns a promise resolving to the val of the key value pair
- sleep (delay) .. returns a promise
- visit (url) .. returns a promise
- waitForTitle (title) ..returns a promise resolving to true if found
- waitForCookie (cookieName) ..returns a promise resolving to a cookie
- waitForUrl () ..returns a promise resolving to the current url
- waitFor (selenium_selector) ..returns a promise resolving to a web element
- whenExists (selenium_selector) ..returns a promise resolving to a web element
- whenEnabled (selenium_selector) ..returns a promise resolving to a web element
- whenDisabled (selenium_selector) ..returns a promise resolving to a web element
- whenVisible (selenium_selector) ..returns a promise resolving to a web element
- whenHidden (selenium_selector) ..returns a promise resolving to a web element
- whenMatches (selenium_selector, val) ..returns a promise resolving to a web element
- whenContains (selenium_selector, val) ..returns a promise resolving to a web element
- sendKeys (selenium_selector, value) ..returns a promise resolving to a web element
- hover (selenium_selector, delay) ..returns a promise resolving to a web element
- click (selenium_selector) ..returns a promise resolving to a web element
- getText (selenium_selector) ..returns a promise resolving to the text within the web element
- getVal (selenium_selector) ..returns a promise resolving to the value of the web element
Install
As a dependency
Tamarin is available as an npm module.
$ npm i tamarin -D
More to come!