From 6e4c730b07df833364fc6bb2e3a940618c95a35d Mon Sep 17 00:00:00 2001 From: Dominik Jelinek Date: Wed, 11 Sep 2024 13:08:02 +0200 Subject: [PATCH] test: fix debug test for VS Code 1.93.x Signed-off-by: Dominik Jelinek --- .../page-objects/src/locators/locators.ts | 14 +++++----- .../test-project/src/test/debug/debug.test.ts | 26 ++++++++++++++++--- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/packages/page-objects/src/locators/locators.ts b/packages/page-objects/src/locators/locators.ts index a5fdfca5f..824526822 100644 --- a/packages/page-objects/src/locators/locators.ts +++ b/packages/page-objects/src/locators/locators.ts @@ -516,7 +516,7 @@ export interface LocatorDiff { export function hasAttribute(attr: string, value?: string, locator?: By): (el: WebElement) => Promise { return async (el: WebElement) => { - el = locator ? el.findElement(locator) : el; + el = locator ? await el.findElement(locator) : el; const attrValue = await el.getAttribute(attr); if (value === undefined) { return attrValue !== null; @@ -527,7 +527,7 @@ export function hasAttribute(attr: string, value?: string, locator?: By): (el: W export function hasClass(classOrPredicate: string | ((klass: string) => boolean), locator?: By): (el: WebElement) => Promise { return async (el: WebElement) => { - el = locator ? el.findElement(locator) : el; + el = locator ? await el.findElement(locator) : el; const klasses = await el.getAttribute('class'); const segments = klasses?.split(/\s+/g); const predicate = typeof classOrPredicate === 'string' ? (klass: string) => klass === classOrPredicate : classOrPredicate; @@ -537,7 +537,7 @@ export function hasClass(classOrPredicate: string | ((klass: string) => boolean) export function hasNotClass(klass: string, locator?: By): (el: WebElement) => Promise { return async (el: WebElement) => { - el = locator ? el.findElement(locator) : el; + el = locator ? await el.findElement(locator) : el; return !(await hasClass(klass).call(undefined, el)); }; } @@ -550,14 +550,14 @@ export function hasElement(locatorSelector: (l: Locators) => By): (el: WebElemen export function fromAttribute(attribute: string, locator?: By): (el: WebElement) => Promise { return async (el: WebElement) => { - el = locator ? el.findElement(locator) : el; - return el.getAttribute(attribute); + el = locator ? await el.findElement(locator) : el; + return await el.getAttribute(attribute); }; } export function fromText(locator?: By): (el: WebElement) => Promise { return async (el: WebElement) => { - el = locator ? el.findElement(locator) : el; - return el.getText(); + el = locator ? await el.findElement(locator) : el; + return await el.getText(); }; } diff --git a/tests/test-project/src/test/debug/debug.test.ts b/tests/test-project/src/test/debug/debug.test.ts index 72aed3360..b0e4aa130 100644 --- a/tests/test-project/src/test/debug/debug.test.ts +++ b/tests/test-project/src/test/debug/debug.test.ts @@ -136,21 +136,39 @@ describe('Debugging', function () { }); it('TextEditor: getBreakpoint works', async function () { - const breakpoint = await editor.getBreakpoint(7); + const breakpoint = (await driver.wait( + async () => await editor.getBreakpoint(7), + 10000, + 'could not find breakpoint at line 7', + )) as Breakpoint; expect(breakpoint).not.undefined; }); it('TextEditor: getBreakpoints works', async function () { - const breakpoints = editor.getBreakpoints(); - expect((await breakpoints).length).equals(2); - expect(await (await breakpoints).at(0)?.getLineNumber()).equals(7); + const breakpoints = (await driver.wait( + async () => await editor.getBreakpoints(), + 10000, + 'could not find breakpoints', + )) as Breakpoint[]; + expect(breakpoints.length).equals(2); + expect(await breakpoints.at(0)?.getLineNumber()).equals(7); }); it('Breakpoint: getLineNumber works', async function () { + breakpoint = (await driver.wait( + async () => await editor.getPausedBreakpoint(), + 10000, + 'could not find paused breakpoint', + )) as Breakpoint; expect(await breakpoint.getLineNumber()).equals(line); }); it('Breakpoint: isPaused works', async function () { + breakpoint = (await driver.wait( + async () => await editor.getPausedBreakpoint(), + 10000, + 'could not find paused breakpoint', + )) as Breakpoint; expect(await breakpoint.isPaused()).to.be.true; });