test: wait for element

This commit is contained in:
tomasz-io 2024-12-06 17:51:52 -08:00
parent 120e46fcbc
commit 8d06b9f381
2 changed files with 4 additions and 7 deletions

View file

@ -5,7 +5,7 @@ export class TestUtils {
locatorFn: () => Promise<WebElement>,
timeout: number = 5000,
interval: number = 500,
): Promise<any> {
): Promise<WebElement> {
const startTime = Date.now();
while (Date.now() - startTime < timeout) {

View file

@ -5,6 +5,7 @@ import {
Workbench,
} from "vscode-extension-tester";
import { GUISelectors } from "../selectors/GUI.selectors";
import { TestUtils } from "../TestUtils";
export class GUIActions {
public static switchToReactIframe = async (driver: WebDriver) => {
@ -49,14 +50,10 @@ export class GUIActions {
const dropdownButton = await GUISelectors.getModelDropdownButton(view);
await dropdownButton.click();
await new Promise((res) => {
setTimeout(res, 2000);
const dropdownOption = await TestUtils.waitForElement(() => {
return GUISelectors.getModelDropdownOption(view, option);
});
const dropdownOption = await GUISelectors.getModelDropdownOption(
view,
option,
);
await dropdownOption.click();
};
}