Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@EeroHeroHeino
Created July 28, 2015 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EeroHeroHeino/2229b705781f0c148589 to your computer and use it in GitHub Desktop.
Save EeroHeroHeino/2229b705781f0c148589 to your computer and use it in GitHub Desktop.
// 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