This library provide a function which wait until an element is visible.
MIT License
This library provide a function which wait until an element is visible.
npm install wait-for-element
if you use it with non promise support browser, should load Promise polyfill like ES6-Promise.
if you use it with old browser.
if (Element && !Element.prototype.matches) {
var proto = Element.prototype;
proto.matches = proto.matchesSelector ||
proto.mozMatchesSelector || proto.msMatchesSelector ||
proto.oMatchesSelector || proto.webkitMatchesSelector;
}
or use polyfill.
wait-for-element do feature detection and use either one of the two.
For details, please see Example.
/**
* Wait until an element that is matched the selector is visible.
* @param {string} selector the css selector
* @param {number} timeout the timeout is millisecond. default:2000ms
* @returns {Promise}
*/
var waitForElement = require("wait-for-element");
waitForElement("#js-element").then(function (element) {
alert("Found #js-element");
}).catch(console.error.bind(console));
npm test
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT