-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[services/testSubjects] fix isDisplayed/isEnabled/isSelected, add waitForEnabled #66538
Changes from 1 commit
ca671f2
fcb66fd
1bcf567
a811206
250a96b
3b8b1d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,12 +97,10 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) { | |
} | ||
|
||
public async append(selector: string, text: string): Promise<void> { | ||
return await retry.try(async () => { | ||
log.debug(`TestSubjects.append(${selector}, ${text})`); | ||
const input = await this.find(selector); | ||
await input.click(); | ||
await input.type(text); | ||
}); | ||
log.debug(`TestSubjects.append(${selector}, ${text})`); | ||
const input = await this.find(selector); | ||
await input.click(); | ||
await input.type(text); | ||
} | ||
|
||
public async clickWhenNotDisabled( | ||
|
@@ -119,12 +117,10 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) { | |
} | ||
|
||
public async doubleClick(selector: string, timeout: number = FIND_TIME): Promise<void> { | ||
return await retry.try(async () => { | ||
log.debug(`TestSubjects.doubleClick(${selector})`); | ||
const element = await this.find(selector, timeout); | ||
await element.moveMouseTo(); | ||
await element.doubleClick(); | ||
}); | ||
log.debug(`TestSubjects.doubleClick(${selector})`); | ||
const element = await this.find(selector, timeout); | ||
await element.moveMouseTo(); | ||
await element.doubleClick(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WebElementWrapper has
I don't think we need to use retry service here |
||
|
||
async descendantExists(selector: string, parentElement: WebElementWrapper): Promise<boolean> { | ||
|
@@ -210,27 +206,21 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) { | |
} | ||
|
||
public async isEnabled(selector: string): Promise<boolean> { | ||
return await retry.try(async () => { | ||
log.debug(`TestSubjects.isEnabled(${selector})`); | ||
const element = await this.find(selector); | ||
return await element.isEnabled(); | ||
}); | ||
log.debug(`TestSubjects.isEnabled(${selector})`); | ||
const element = await this.find(selector); | ||
return await element.isEnabled(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same reason as with |
||
} | ||
|
||
public async isDisplayed(selector: string): Promise<boolean> { | ||
return await retry.try(async () => { | ||
log.debug(`TestSubjects.isDisplayed(${selector})`); | ||
const element = await this.find(selector); | ||
return await element.isDisplayed(); | ||
}); | ||
log.debug(`TestSubjects.isDisplayed(${selector})`); | ||
const element = await this.find(selector); | ||
return await element.isDisplayed(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same reason as with |
||
} | ||
|
||
public async isSelected(selector: string): Promise<boolean> { | ||
return await retry.try(async () => { | ||
log.debug(`TestSubjects.isSelected(${selector})`); | ||
const element = await this.find(selector); | ||
return await element.isSelected(); | ||
}); | ||
log.debug(`TestSubjects.isSelected(${selector})`); | ||
const element = await this.find(selector); | ||
return await element.isSelected(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same reason as with |
||
} | ||
|
||
public async isSelectedAll(selectorAll: string): Promise<boolean[]> { | ||
|
@@ -241,11 +231,9 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) { | |
} | ||
|
||
public async getVisibleText(selector: string): Promise<string> { | ||
return await retry.try(async () => { | ||
log.debug(`TestSubjects.getVisibleText(${selector})`); | ||
const element = await this.find(selector); | ||
return await element.getVisibleText(); | ||
}); | ||
log.debug(`TestSubjects.getVisibleText(${selector})`); | ||
const element = await this.find(selector); | ||
return await element.getVisibleText(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same reason as with |
||
} | ||
|
||
async getVisibleTextAll(selectorAll: string): Promise<string[]> { | ||
|
@@ -298,6 +286,13 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) { | |
await find.waitForElementHidden(element, timeout); | ||
} | ||
|
||
public async waitForEnabled(selector: string, timeout: number = TRY_TIME): Promise<void> { | ||
await retry.tryForTime(timeout, async () => { | ||
const element = await this.find(selector); | ||
return (await element.isDisplayed()) && (await element.isEnabled()); | ||
}); | ||
} | ||
|
||
public getCssSelector(selector: string): string { | ||
return testSubjSelector(selector); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we don't clear input after click, retrying it may end up with the incorrect text