Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(waitFor): replaced page.waitFor by its successor page.waitForTimeout #1277

Merged
merged 1 commit into from Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should page.waitForSelector be used here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That indeed not backward compatible, if someone is using an xpath expression rather then a CSS selector, this previously worked. But would no longer work afterwards.

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