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

Add retry to find.existsByDisplayedByCssSelector #48734

Merged
merged 13 commits into from
Nov 18, 2019
Merged
2 changes: 0 additions & 2 deletions test/functional/apps/dashboard/dashboard_snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export default function ({ getService, getPageObjects, updateBaselines }) {
await PageObjects.common.closeToast();

await PageObjects.dashboard.saveDashboard('tsvb');
await PageObjects.common.closeToast();
await PageObjects.dashboard.clickFullScreenMode();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickExpandPanelToggle();
Expand All @@ -74,7 +73,6 @@ export default function ({ getService, getPageObjects, updateBaselines }) {
await PageObjects.common.closeToast();

await PageObjects.dashboard.saveDashboard('area');
await PageObjects.common.closeToast();
await PageObjects.dashboard.clickFullScreenMode();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickExpandPanelToggle();
Expand Down
6 changes: 5 additions & 1 deletion test/functional/page_objects/dashboard_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ export function DashboardPageProvider({ getService, getPageObjects }) {

/**
* Save the current dashboard with the specified name and options and
* verify that the save was successful
* verify that the save was successful, close the toast and return the
* toast message
*
* @param dashName {String}
* @param saveOptions {{storeTimeWithDashboard: boolean, saveAsNew: boolean, needsConfirm: false, waitDialogIsClosed: boolean }}
Expand All @@ -319,8 +320,11 @@ export function DashboardPageProvider({ getService, getPageObjects }) {

// Confirm that the Dashboard has actually been saved
await testSubjects.existOrFail('saveDashboardSuccess');
const message = await PageObjects.common.closeToast();
await PageObjects.header.waitUntilLoadingHasFinished();
await this.waitForSaveModalToClose();

return message;
}

async waitForSaveModalToClose() {
Expand Down
20 changes: 16 additions & 4 deletions test/functional/services/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,22 @@ export async function FindProvider({ getService }: FtrProviderContext) {
timeout: number = WAIT_FOR_EXISTS_TIME
): Promise<boolean> {
log.debug(`Find.existsByDisplayedByCssSelector('${selector}') with timeout=${timeout}`);
return await this.exists(async drive => {
const elements = wrapAll(await drive.findElements(By.css(selector)));
return await this.filterElementIsDisplayed(elements);
}, timeout);
try {
await retry.tryForTime(timeout, async () => {
// make sure that the find timeout is not longer than the retry timeout
await this._withTimeout(Math.min(timeout, WAIT_FOR_EXISTS_TIME));
const elements = await driver.findElements(By.css(selector));
await this._withTimeout(defaultFindTimeout);
const displayed = await this.filterElementIsDisplayed(wrapAll(elements));
if (displayed.length === 0) {
throw new Error(`${selector} is not displayed`);
}
});
} catch (err) {
await this._withTimeout(defaultFindTimeout);
return false;
}
return true;
}

public async existsByCssSelector(
Expand Down