Skip to content

Commit

Permalink
Adding wait for button to exist
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Grossmann <lgrossma@redhat.com>
  • Loading branch information
lgrossma authored and vrubezhny committed Jul 12, 2024
1 parent a172f1d commit e2e6002
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/ui/common/ui/webview/newComponentWebViewEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class LocalCodeBasePage extends Page {

public async clickCreateComponent(): Promise<void> {
await this.enterWebView(async (webView) => {
const button = await this.getCreateComponentButton(webView);
const button = await this.createButtonExists(webView);
await button.click();
});
}
Expand All @@ -221,6 +221,19 @@ export class LocalCodeBasePage extends Page {
return await webView.findWebElement(By.xpath('//button[contains(text(), "Select Folder")]'));
}

private async createButtonExists(webView: WebView, timeout = 60_000): Promise<WebElement> {
return webView.getDriver().wait(async () => {
try {
const button = await this.getCreateComponentButton(webView);
if (button) {
return button;
}
} catch (err) {
return null;
}
}, timeout);
}

private async getCreateComponentButton(webView: WebView): Promise<WebElement> {
return await webView.findWebElement(By.xpath('//span[contains(text(), "Create Component")]'));
}
Expand Down

0 comments on commit e2e6002

Please sign in to comment.