Created
July 28, 2015 14:40
-
-
Save EeroHeroHeino/2229b705781f0c148589 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add js step before this step which defines | |
// - GLOBALS.not_showing CSS locator | |
// - GLOBALS.poll_time to optionally wait a different time than 3 seconds | |
if (!GLOBALS.not_showing) { | |
callback("JS-step GLOBALS.not_showing not set"); | |
} | |
var locator = GLOBALS.not_showing; | |
if (!GLOBALS.poll_time) { | |
var poll_timeout_seconds = 3; | |
} else { | |
var poll_timeout_seconds = GLOBALS.poll_time; | |
} | |
var poll_timeout_seconds = 3; | |
var poll_frequency_ms = 300; | |
var counter = 0; | |
var max_loops = Math.round(poll_timeout_seconds * 1000 / poll_frequency_ms); | |
var fn = function waitLoop() { | |
// picture is loaded if it has width | |
var img_element = document.querySelector(locator); | |
if (img_element) { | |
return callback("Image locator ("+locator+") not found") | |
} | |
else { | |
if (counter == max_loops) { | |
return callback(true); | |
} | |
counter++; | |
return setTimeout(waitLoop, poll_frequency_ms); | |
} | |
} | |
fn(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment