Tests: Wait for dashboard save button to be enabled before clicking. (#23539)

* Fixes #21446

An attempt to fix the above by making sure the click only happens when the button is enabled.

* Fix wrong function name

* Fix mistakes
This commit is contained in:
Stacey Gammon 2018-10-04 13:27:48 -04:00 committed by GitHub
parent 37bed9b51b
commit 8b0b5b3ac6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 10 deletions

View file

@ -348,10 +348,8 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
}
async clickSave() {
await retry.try(async () => {
log.debug('clicking final Save button for named dashboard');
return await testSubjects.click('confirmSaveSavedObjectButton');
});
log.debug('DashboardPage.clickSave');
await testSubjects.clickWhenNotDisabled('confirmSaveSavedObjectButton');
}
/**

View file

@ -187,6 +187,28 @@ export function FindProvider({ getService }) {
return await this.exists(async remote => await remote.findByCssSelector(selector), timeout);
}
async clickByCssSelectorWhenNotDisabled(selector, { timeout } = { timeout: defaultFindTimeout }) {
log.debug(`Find.clickByCssSelectorWhenNotDisabled`);
// Don't wrap this code in a retry, or stale element checks may get caught here and the element
// will never be re-grabbed. Let errors bubble, but continue checking for disabled property until
// it's gone.
const element = await this.byCssSelector(selector, timeout);
await remote.moveMouseTo(element);
const clickIfNotDisabled = async (element, resolve) => {
const disabled = await element.getProperty('disabled');
if (disabled) {
log.debug('Element is disabled, try again');
setTimeout(() => clickIfNotDisabled(element, resolve), 250);
} else {
await element.click();
resolve();
}
};
await new Promise(resolve => clickIfNotDisabled(element, resolve));
}
async clickByPartialLinkText(linkText, timeout = defaultFindTimeout) {
log.debug(`clickByPartialLinkText(${linkText})`);
await retry.try(async () => {

View file

@ -63,13 +63,14 @@ export function TestSubjectsProvider({ getService }) {
});
}
async clickWhenNotDisabled(selector, { timeout } = { timeout: defaultFindTimeout }) {
log.debug(`TestSubjects.click(${selector})`);
await find.clickByCssSelectorWhenNotDisabled(testSubjSelector(selector), { timeout });
}
async click(selector, timeout = defaultFindTimeout) {
log.debug(`TestSubjects.click(${selector})`);
return await retry.try(async () => {
const element = await this.find(selector, timeout);
await remote.moveMouseTo(element);
await element.click();
});
await find.clickByCssSelector(testSubjSelector(selector), timeout);
}
async doubleClick(selector, timeout = defaultFindTimeout) {
@ -81,7 +82,6 @@ export function TestSubjectsProvider({ getService }) {
});
}
async descendantExists(selector, parentElement) {
return await find.descendantExistsByCssSelector(testSubjSelector(selector), parentElement);
}