[ML] Fix flaky setValue for some elements (#46693) (#47096)

Use setValue with clearing via keyboard
This commit is contained in:
Robert Oskamp 2019-10-02 15:33:15 +02:00 committed by GitHub
parent eba3c17ef7
commit 8019844732
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

View file

@ -27,6 +27,10 @@ interface ExistsOptions {
allowHidden?: boolean;
}
interface ClearOptions {
withKeyboard: boolean;
}
export function TestSubjectsProvider({ getService }: FtrProviderContext) {
const log = getService('log');
const retry = getService('retry');
@ -151,7 +155,11 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {
});
}
public async setValue(selector: string, text: string): Promise<void> {
public async setValue(
selector: string,
text: string,
options: ClearOptions = { withKeyboard: false }
): Promise<void> {
return await retry.try(async () => {
log.debug(`TestSubjects.setValue(${selector}, ${text})`);
await this.click(selector);
@ -159,7 +167,11 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {
// call clearValue() and type() on the element that is focused after
// clicking on the testSubject
const input = await find.activeElement();
await input.clearValue();
if (options.withKeyboard === true) {
await input.clearValueWithKeyboard();
} else {
await input.clearValue();
}
await input.type(text);
});
}

View file

@ -181,15 +181,17 @@ export function MachineLearningJobWizardCommonProvider({ getService }: FtrProvid
},
async setBucketSpan(bucketSpan: string) {
await testSubjects.setValue('mlJobWizardInputBucketSpan', bucketSpan);
await testSubjects.setValue('mlJobWizardInputBucketSpan', bucketSpan, { withKeyboard: true });
},
async setJobId(jobId: string) {
await testSubjects.setValue('mlJobWizardInputJobId', jobId);
await testSubjects.setValue('mlJobWizardInputJobId', jobId, { withKeyboard: true });
},
async setJobDescription(jobDescription: string) {
await testSubjects.setValue('mlJobWizardInputJobDescription', jobDescription);
await testSubjects.setValue('mlJobWizardInputJobDescription', jobDescription, {
withKeyboard: true,
});
},
async addJobGroup(jobGroup: string) {
@ -216,7 +218,9 @@ export function MachineLearningJobWizardCommonProvider({ getService }: FtrProvid
},
async setModelMemoryLimit(modelMemoryLimit: string) {
await testSubjects.setValue('mlJobWizardInputModelMemoryLimit', modelMemoryLimit);
await testSubjects.setValue('mlJobWizardInputModelMemoryLimit', modelMemoryLimit, {
withKeyboard: true,
});
},
async createJobAndWaitForCompletion() {