Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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