Skip to content

Commit

Permalink
refactor(waitFor): replaced .waitFor by its successor .waitForTimeout (
Browse files Browse the repository at this point in the history
  • Loading branch information
mfranzke committed Feb 3, 2021
1 parent 024f81b commit 5702987
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions capture/engine_scripts/puppet/clickAndHoverHelper.js
Expand Up @@ -7,31 +7,31 @@ module.exports = async (page, scenario) => {

if (keyPressSelector) {
for (const keyPressSelectorItem of [].concat(keyPressSelector)) {
await page.waitFor(keyPressSelectorItem.selector);
await page.waitForTimeout(keyPressSelectorItem.selector);
await page.type(keyPressSelectorItem.selector, keyPressSelectorItem.keyPress);
}
}

if (hoverSelector) {
for (const hoverSelectorIndex of [].concat(hoverSelector)) {
await page.waitFor(hoverSelectorIndex);
await page.waitForTimeout(hoverSelectorIndex);
await page.hover(hoverSelectorIndex);
}
}

if (clickSelector) {
for (const clickSelectorIndex of [].concat(clickSelector)) {
await page.waitFor(clickSelectorIndex);
await page.waitForTimeout(clickSelectorIndex);
await page.click(clickSelectorIndex);
}
}

if (postInteractionWait) {
await page.waitFor(postInteractionWait);
await page.waitForTimeout(postInteractionWait);
}

if (scrollToSelector) {
await page.waitFor(scrollToSelector);
await page.waitForTimeout(scrollToSelector);
await page.evaluate(scrollToSelector => {
document.querySelector(scrollToSelector).scrollIntoView();
}, scrollToSelector);
Expand Down
4 changes: 2 additions & 2 deletions core/util/runPuppet.js
Expand Up @@ -132,13 +132,13 @@ async function processScenarioView (scenario, variantOrScenarioLabelSafe, scenar

// --- WAIT FOR SELECTOR ---
if (scenario.readySelector) {
await page.waitFor(scenario.readySelector);
await page.waitForTimeout(scenario.readySelector);
}
//

// --- DELAY ---
if (scenario.delay > 0) {
await page.waitFor(scenario.delay);
await page.waitForTimeout(scenario.delay);
}

// --- REMOVE SELECTORS ---
Expand Down
Expand Up @@ -4,16 +4,16 @@ module.exports = async (page, scenario) => {
const postInteractionWait = scenario.postInteractionWait; // selector [str] | ms [int]

if (hoverSelector) {
await page.waitFor(hoverSelector);
await page.waitForTimeout(hoverSelector);
await page.hover(hoverSelector);
}

if (clickSelector) {
await page.waitFor(clickSelector);
await page.waitForTimeout(clickSelector);
await page.click(clickSelector);
}

if (postInteractionWait) {
await page.waitFor(postInteractionWait);
await page.waitForTimeout(postInteractionWait);
}
};
Expand Up @@ -6,24 +6,24 @@ module.exports = async (page, scenario) => {

if (hoverSelector) {
for (const hoverSelectorIndex of [].concat(hoverSelector)) {
await page.waitFor(hoverSelectorIndex);
await page.waitForTimeout(hoverSelectorIndex);
await page.hover(hoverSelectorIndex);
}
}

if (clickSelector) {
for (const clickSelectorIndex of [].concat(clickSelector)) {
await page.waitFor(clickSelectorIndex);
await page.waitForTimeout(clickSelectorIndex);
await page.click(clickSelectorIndex);
}
}

if (postInteractionWait) {
await page.waitFor(postInteractionWait);
await page.waitForTimeout(postInteractionWait);
}

if (scrollToSelector) {
await page.waitFor(scrollToSelector);
await page.waitForTimeout(scrollToSelector);
await page.evaluate(scrollToSelector => {
document.querySelector(scrollToSelector).scrollIntoView();
}, scrollToSelector);
Expand Down
Expand Up @@ -7,27 +7,27 @@ module.exports = async (page, scenario) => {

if (keyPressSelector) {
for (const keyPressSelectorItem of [].concat(keyPressSelector)) {
await page.waitFor(keyPressSelectorItem.selector);
await page.waitForTimeout(keyPressSelectorItem.selector);
await page.type(keyPressSelectorItem.selector, keyPressSelectorItem.keyPress);
}
}

if (hoverSelector) {
await page.waitFor(hoverSelector);
await page.waitForTimeout(hoverSelector);
await page.hover(hoverSelector);
}

if (clickSelector) {
await page.waitFor(clickSelector);
await page.waitForTimeout(clickSelector);
await page.click(clickSelector);
}

if (postInteractionWait) {
await page.waitFor(postInteractionWait);
await page.waitForTimeout(postInteractionWait);
}

if (scrollToSelector) {
await page.waitFor(scrollToSelector);
await page.waitForTimeout(scrollToSelector);
await page.evaluate(scrollToSelector => {
document.querySelector(scrollToSelector).scrollIntoView();
}, scrollToSelector);
Expand Down

0 comments on commit 5702987

Please sign in to comment.