diff --git a/WebExample/tests/input.spec.ts b/WebExample/tests/input.spec.ts index a63968bc..0e291929 100644 --- a/WebExample/tests/input.spec.ts +++ b/WebExample/tests/input.spec.ts @@ -31,15 +31,15 @@ test.describe('standard input behaviour', () => { expect(await inputLocator.innerText()).toBe(EXAMPLE_LONG_CONTENT); - const cursorPosition = await page.evaluate((selector) => { - const editableDiv = document.querySelector(selector) as HTMLElement; + const cursorPosition = await page.evaluate(() => { + const editableDiv = document.querySelector('div[contenteditable="true"]') as HTMLElement; const range = window.getSelection()?.getRangeAt(0); if (!range || !editableDiv) return null; const preCaretRange = range.cloneRange(); preCaretRange.selectNodeContents(editableDiv); preCaretRange.setEnd(range.endContainer, range.endOffset); return preCaretRange.toString().length; - }, 'div[contenteditable="true"]'); + }); expect(cursorPosition).toBe(EXAMPLE_LONG_CONTENT.length); }); diff --git a/WebExample/tests/textManipulation.spec.ts b/WebExample/tests/textManipulation.spec.ts index e99fcca1..37978124 100644 --- a/WebExample/tests/textManipulation.spec.ts +++ b/WebExample/tests/textManipulation.spec.ts @@ -97,6 +97,7 @@ test.describe('paste content', () => { test('select', async ({page}) => { const inputLocator = await setupInput(page, 'reset'); await inputLocator.focus(); + await inputLocator.press(`${OPERATION_MODIFIER}+a`); const cursorPosition = await page.evaluate(() => { const editableDiv = document.querySelector('div[contenteditable="true"]'); @@ -105,6 +106,7 @@ test('select', async ({page}) => { const preCaretRange = range.cloneRange(); preCaretRange.selectNodeContents(editableDiv); preCaretRange.setEnd(range.endContainer, range.endOffset); + return preCaretRange.toString().length; });