diff --git a/packages/page-objects/src/components/editor/TextEditor.ts b/packages/page-objects/src/components/editor/TextEditor.ts index 93356531a..0e3ede532 100644 --- a/packages/page-objects/src/components/editor/TextEditor.ts +++ b/packages/page-objects/src/components/editor/TextEditor.ts @@ -626,6 +626,32 @@ export class TextEditor extends Editor { return new Breakpoint(breakpoints[0], lineElement); } + /** + * Get all breakpoints. + * @returns List of Breakpoints. + */ + async getBreakpoints(): Promise { + const breakpoints: Breakpoint[] = []; + + const breakpointLocators = Breakpoint.locators.TextEditor.breakpoint; + const breakpointContainer = TextEditor.versionInfo.version >= '1.80.0' ? await this.findElement(By.className('glyph-margin-widgets')) : this; + const breakpointsSelectors = await breakpointContainer.findElements(breakpointLocators.generalSelector); + + for (const breakpointSelector of breakpointsSelectors) { + let lineElement: WebElement; + if (TextEditor.versionInfo.version >= '1.80.0') { + const styleTopAttr = await breakpointSelector.getCssValue('top'); + lineElement = await this.findElement(TextEditor.locators.TextEditor.marginArea).findElement( + By.xpath(`.//div[contains(@style, "${styleTopAttr}")]`), + ); + } else { + lineElement = await breakpointSelector.findElement(By.xpath('./..')); + } + breakpoints.push(new Breakpoint(breakpointSelector, lineElement)); + } + return breakpoints; + } + /** * Get all code lenses within the editor * @returns list of CodeLens page objects diff --git a/tests/test-project/src/test/debug/debug.test.ts b/tests/test-project/src/test/debug/debug.test.ts index 28843cd65..5bab17ad7 100644 --- a/tests/test-project/src/test/debug/debug.test.ts +++ b/tests/test-project/src/test/debug/debug.test.ts @@ -135,6 +135,12 @@ describe('Debugging', function () { )) as Breakpoint; }); + 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); + }); + it('Breakpoint: getLineNumber works', async function () { expect(await breakpoint.getLineNumber()).equals(line); });