A pullstream "webdriver" for interacting with changes to the dom.
A pullstream "webdriver" for interacting with changes to the dom.
When you're testing client side apps like react or inu, finding and interacting with elements that appear dynamically is painful. pull-dom-driver uses a pull-stream source of dom mutations from pull-dom-mutants to find(".list")
and click("#go-button")
on elements once they're actually in the dom.
Let's find an element that isn't in the dom yet but will be:
//in the browser
var createDomStream = require('pull-dom-driver')
var pull = require('pull-stream')
var domStream = createDomStream(document, window)
pull(
domStream.find('#mutant')
pull.drain((elem) => console.log(`I found this: ${elem}`))
)
var myDiv = document.createElement('div')
myDiv.id = "mutant"
document.body.appendChild(myDiv)
This will output
"I found this: [object HTMLDivElement]"
Takes the rootElement
on which you'd like to obseve changes.
Returns an object with the following keys:
subscribe
find
click
Takes a cssSelectorString
for the element(s) you'd like to find.
Returns a pull-stream source of elements that have been found in the dom.
Note that if there is an element that matches the selector when the stream is created it will be emitted by the stream first.
Takes a cssSelectorString
for the element(s) you'd like to click on.
Returns a pull-stream source of elements that have been clicked in the dom.
Note that if there is an element(s) that matches the selector when the stream is created it will be emitted by the stream first.
Returns a pull-stream source of dom mutations from pull-dom-mutants
With npm installed, run
$ npm install pull-dom-driver
pull-dom-driver was inspired by..
MIT