diff --git a/packages/page-objects/src/components/editor/TextEditor.ts b/packages/page-objects/src/components/editor/TextEditor.ts index 0e3ede532..523c0f9a7 100644 --- a/packages/page-objects/src/components/editor/TextEditor.ts +++ b/packages/page-objects/src/components/editor/TextEditor.ts @@ -626,6 +626,21 @@ export class TextEditor extends Editor { return new Breakpoint(breakpoints[0], lineElement); } + /** + * Get paused breakpoint on line if available. Otherwise, return undefined. + * @param line number of the line to retrieve + * @returns promise which resolves to either Breakpoint page object or undefined + */ + async getBreakpoint(line: number): Promise { + const breakpoints = await this.getBreakpoints(); + for (const breakpoint of breakpoints) { + if ((await breakpoint.getLineNumber()) === line) { + return breakpoint; + } + } + return undefined; + } + /** * Get all breakpoints. * @returns List of Breakpoints. diff --git a/tests/test-project/src/test/debug/debug.test.ts b/tests/test-project/src/test/debug/debug.test.ts index 5bab17ad7..72aed3360 100644 --- a/tests/test-project/src/test/debug/debug.test.ts +++ b/tests/test-project/src/test/debug/debug.test.ts @@ -135,6 +135,11 @@ describe('Debugging', function () { )) as Breakpoint; }); + it('TextEditor: getBreakpoint works', async function () { + const breakpoint = await editor.getBreakpoint(7); + expect(breakpoint).not.undefined; + }); + it('TextEditor: getBreakpoints works', async function () { const breakpoints = editor.getBreakpoints(); expect((await breakpoints).length).equals(2);