Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!GLOBALS.poll_time) {
- var poll_timeout_seconds = 3;
- } else {
- var poll_timeout_seconds = GLOBALS.poll_time;
- }
- var element = "iframe.locator";
- var element_text = "Text to check";
- var poll_frequency_ms = 500;
- var counter = 0;
- var max_loops = Math.round(poll_timeout_seconds * 1000 / poll_frequency_ms);
- var checkIframeTextPresent = function (locator, text) {
- if ($(locator).length == 0) return false;
- return $(locator)[0].contentWindow.document.body.textContent.indexOf(text) !== -1;
- };
- var fn = function waitLoop() {
- if (checkIframeTextPresent(element, element_text)) {
- callback(true);
- } else {
- if (counter == max_loops) {
- return callback("Couldn't find text '"+element_text+"' inside "+element+" in "+poll_timeout_seconds+"s");
- //return callback(true);
- }
- counter++;
- setTimeout(waitLoop, 1000);
- }
- }
- fn();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement