diff --git a/ketcher-autotests/tests/Structure-Creating-&-Editing/Actions-With-Structures/Rectangle selection/rectangle-tool.spec.ts b/ketcher-autotests/tests/Structure-Creating-&-Editing/Actions-With-Structures/Rectangle selection/rectangle-tool.spec.ts index fd711c3702..fc5f2fd67f 100644 --- a/ketcher-autotests/tests/Structure-Creating-&-Editing/Actions-With-Structures/Rectangle selection/rectangle-tool.spec.ts +++ b/ketcher-autotests/tests/Structure-Creating-&-Editing/Actions-With-Structures/Rectangle selection/rectangle-tool.spec.ts @@ -38,7 +38,7 @@ test.describe('Rectangle selection tool', () => { const selectionCoords = { x: 300, y: 200 }; async function clickCanvas(page: Page) { - await page.mouse.click(selectionCoords.x, selectionCoords.y); + await clickOnCanvas(page, selectionCoords.x, selectionCoords.y); } test('Structure selection with rectangle selection tool', async ({ diff --git a/ketcher-autotests/tests/Structure-Creating-&-Editing/SMARTS-attributes/Reaction-queries-attributes/reaction-queries-attributes.spec.ts b/ketcher-autotests/tests/Structure-Creating-&-Editing/SMARTS-attributes/Reaction-queries-attributes/reaction-queries-attributes.spec.ts index 8d39256b57..58b2aa93aa 100644 --- a/ketcher-autotests/tests/Structure-Creating-&-Editing/SMARTS-attributes/Reaction-queries-attributes/reaction-queries-attributes.spec.ts +++ b/ketcher-autotests/tests/Structure-Creating-&-Editing/SMARTS-attributes/Reaction-queries-attributes/reaction-queries-attributes.spec.ts @@ -49,7 +49,7 @@ async function drawStructureWithArrowOpenAngle(page: Page) { await resetCurrentTool(page); await page.mouse.move(x, y + shiftForCoordinatesToResetArrowOpenAngleTool); - await page.mouse.click; + await clickOnCanvas; await selectAtomInToolbar(AtomButton.Oxygen, page); await clickOnCanvas(page, x + shiftForOxygen, y, { diff --git a/ketcher-autotests/tests/utils/canvas/bonds/example.spec.ts b/ketcher-autotests/tests/utils/canvas/bonds/example.spec.ts index e6641d3ec9..07ab4221da 100644 --- a/ketcher-autotests/tests/utils/canvas/bonds/example.spec.ts +++ b/ketcher-autotests/tests/utils/canvas/bonds/example.spec.ts @@ -1,6 +1,6 @@ export {}; // import { test } from '@playwright/test'; -// import { drawElementByTitle, waitForPageInit } from '@utils'; +// import { drawElementByTitle, waitForPageInit, clickOnCanvas, } from '@utils'; // import { // getRightBondByAttributes, // getBottomBondByAttributes, @@ -32,7 +32,7 @@ export {}; // { type: BondType.HYDROGEN }, // searchedIndex, // ); -// await page.mouse.click(bondByIndex.x, bondByIndex.y); +// await clickOnCanvas(page, bondByIndex.x, bondByIndex.y); // const leftBond = await getLeftBondByAttributes(page, { // topology: 1, @@ -40,19 +40,19 @@ export {}; // sb: 2, // reactingCenterStatus: 2, // }); -// await page.mouse.click(leftBond.x, leftBond.y); +// await clickOnCanvas(page, leftBond.x, leftBond.y); // const rBond = await getRightBondByAttributes(page, { // stereo: 2, // type: BondType.DATIVE, // }); -// await page.mouse.click(rBond.x, rBond.y); +// await clickOnCanvas(page, rBond.x, rBond.y); // const bottomBond = await getBottomBondByAttributes(page, { sa: 1 }); -// await page.mouse.click(bottomBond.x, bottomBond.y); +// await clickOnCanvas(page, bottomBond.x, bottomBond.y); // const topBond = await getTopBondByAttributes(page, { type: BondType.DOUBLE }); -// await page.mouse.click(topBond.x, topBond.y); +// await clickOnCanvas(page, topBond.x, topBond.y); // }); // test(`ATOM`, async ({ page }) => { @@ -60,26 +60,26 @@ export {}; // await drawElementByTitle(page, ELEMENT_TITLE.BENZENE, OFFSET_X, OFFSET_Y); // const firstAtom = await getAtomByIndex(page, { label: 'C', valence: 1 }, 0); -// await page.mouse.click(firstAtom.x, firstAtom.y); +// await clickOnCanvas(page, firstAtom.x, firstAtom.y); // const leftAtom = await getLeftAtomByAttributes(page, { // stereoParity: 1, // }); -// await page.mouse.click(leftAtom.x, leftAtom.y); +// await clickOnCanvas(page, leftAtom.x, leftAtom.y); // const rightAtom = await getRightAtomByAttributes(page, { // exactChangeFlag: 2, // hCount: 1, // charge: 2, // }); -// await page.mouse.click(rightAtom.x, rightAtom.y); +// await clickOnCanvas(page, rightAtom.x, rightAtom.y); // const bottomAtom = await getBottomAtomByAttributes(page, { charge: 1 }); -// await page.mouse.click(bottomAtom.x, bottomAtom.y); +// await clickOnCanvas(page, bottomAtom.x, bottomAtom.y); // const topAtom = await getTopAtomByAttributes(page, { // substitutionCount: 1, // valence: 3, // }); -// await page.mouse.click(topAtom.x, topAtom.y); +// await clickOnCanvas(page, topAtom.x, topAtom.y); // }); diff --git a/ketcher-autotests/tests/utils/canvas/tools/helpers.ts b/ketcher-autotests/tests/utils/canvas/tools/helpers.ts index 4ecd4536f9..faf577697a 100644 --- a/ketcher-autotests/tests/utils/canvas/tools/helpers.ts +++ b/ketcher-autotests/tests/utils/canvas/tools/helpers.ts @@ -196,7 +196,7 @@ export async function selectClearCanvasTool(page: Page, maxAttempts = 10) { return; } catch (error) { attempts++; - await page.mouse.click(0, 0); + await clickOnCanvas(page, 0, 0); await page.keyboard.press('Escape'); if (await closeWindowXButton.isVisible()) { await closeWindowXButton.click(); diff --git a/ketcher-autotests/tests/utils/clicks/index.ts b/ketcher-autotests/tests/utils/clicks/index.ts index 529df0113c..a66f04d391 100644 --- a/ketcher-autotests/tests/utils/clicks/index.ts +++ b/ketcher-autotests/tests/utils/clicks/index.ts @@ -77,7 +77,7 @@ export async function clickOnCanvas( }, ) { await waitForRender(page, async () => { - await page.mouse.click(x, y, options); + await clickOnCanvas(page, x, y, options); }); } @@ -143,7 +143,8 @@ export async function clickOnTheCanvas( page, ); await waitForRender(page, async () => { - await page.mouse.click( + await clickOnCanvas( + page, secondStructureCoordinates.x + xOffsetFromCenter, secondStructureCoordinates.y + yOffsetFromCenter, ); @@ -152,9 +153,7 @@ export async function clickOnTheCanvas( export async function clickOnMiddleOfCanvas(page: Page) { const middleOfCanvas = await getCoordinatesOfTheMiddleOfTheCanvas(page); - await waitForRender(page, async () => { - await page.mouse.click(middleOfCanvas.x, middleOfCanvas.y); - }); + await clickOnCanvas(page, middleOfCanvas.x, middleOfCanvas.y); } export async function clickByLink(page: Page, url: string) { @@ -168,9 +167,7 @@ export async function clickOnBond( buttonSelect?: 'left' | 'right' | 'middle', ) { const point = await getBondByIndex(page, { type: bondType }, bondNumber); - await waitForRender(page, async () => { - await page.mouse.click(point.x, point.y, { button: buttonSelect }); - }); + await clickOnCanvas(page, point.x, point.y, { button: buttonSelect }); } export async function clickOnBondById( @@ -179,9 +176,7 @@ export async function clickOnBondById( buttonSelect?: 'left' | 'right' | 'middle', ) { const point = await getBondById(page, bondId); - await waitForRender(page, async () => { - await page.mouse.click(point.x, point.y, { button: buttonSelect }); - }); + await clickOnCanvas(page, point.x, point.y, { button: buttonSelect }); } export async function clickOnAtom( @@ -191,9 +186,7 @@ export async function clickOnAtom( buttonSelect?: 'left' | 'right' | 'middle', ) { const point = await getAtomByIndex(page, { label: atomLabel }, atomNumber); - await waitForRender(page, async () => { - await page.mouse.click(point.x, point.y, { button: buttonSelect }); - }); + await clickOnCanvas(page, point.x, point.y, { button: buttonSelect }); } export async function clickOnAtomById( @@ -202,9 +195,7 @@ export async function clickOnAtomById( buttonSelect?: 'left' | 'right' | 'middle', ) { const point = await getAtomById(page, atomId); - await waitForRender(page, async () => { - await page.mouse.click(point.x, point.y, { button: buttonSelect }); - }); + await clickOnCanvas(page, point.x, point.y, { button: buttonSelect }); } export async function doubleClickOnAtom( @@ -213,9 +204,7 @@ export async function doubleClickOnAtom( atomNumber: number, ) { const point = await getAtomByIndex(page, { label: atomLabel }, atomNumber); - await waitForRender(page, async () => { - await page.mouse.dblclick(point.x, point.y); - }); + await clickOnCanvas(page, point.x, point.y); } export async function doubleClickOnBond( @@ -235,7 +224,7 @@ export async function rightClickOnBond( bondNumber: number, ) { const point = await getBondByIndex(page, { type: bondType }, bondNumber); - await page.mouse.click(point.x, point.y, { button: 'right' }); + await clickOnCanvas(page, point.x, point.y, { button: 'right' }); } export async function moveOnAtom( diff --git a/ketcher-autotests/tests/utils/macromolecules/polymerBond.ts b/ketcher-autotests/tests/utils/macromolecules/polymerBond.ts index 167998a98b..a002f92de6 100644 --- a/ketcher-autotests/tests/utils/macromolecules/polymerBond.ts +++ b/ketcher-autotests/tests/utils/macromolecules/polymerBond.ts @@ -1,7 +1,7 @@ /* eslint-disable no-magic-numbers */ import { Locator, Page } from '@playwright/test'; import { hideMonomerPreview } from '@utils/macromolecules/index'; -import { moveMouseAway, selectMacroBond } from '..'; +import { clickOnCanvas, moveMouseAway, selectMacroBond } from '..'; import { DropdownToolIds } from '@utils/clicks/types'; import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; @@ -279,7 +279,8 @@ export async function clickOnMicroBondByIndex(page: Page, bondIndex: number) { // Simple click on element doesn't work always because only black pixels of bond are clickable (what? YES!) // So, bonds with empty space in the center (for example - double bond) are not clickable if (boundingBox) { - await page.mouse.click( + await clickOnCanvas( + page, boundingBox.x + boundingBox.width / 2 + 2, boundingBox.y + boundingBox.height / 2 + 2, ); diff --git a/ketcher-autotests/tests/utils/selectors/templateModal.ts b/ketcher-autotests/tests/utils/selectors/templateModal.ts index 13197da092..3fa8a45cdd 100644 --- a/ketcher-autotests/tests/utils/selectors/templateModal.ts +++ b/ketcher-autotests/tests/utils/selectors/templateModal.ts @@ -9,6 +9,7 @@ import { takeEditorScreenshot, STRUCTURE_LIBRARY_BUTTON_NAME, pressButton, + clickOnCanvas, } from '@utils'; import { ElementLabel } from 'ketcher-core'; @@ -333,12 +334,12 @@ const COORDS_CLICK = { Function for attaching structures on top of bonds attached on Benzene ring */ export async function attachOnTopOfBenzeneBonds(page: Page) { - await page.mouse.click(COORDS_CLICK.x1, COORDS_CLICK.y1); - await page.mouse.click(COORDS_CLICK.x2, COORDS_CLICK.y2); - await page.mouse.click(COORDS_CLICK.x3, COORDS_CLICK.y3); - await page.mouse.click(COORDS_CLICK.x4, COORDS_CLICK.y4); - await page.mouse.click(COORDS_CLICK.x5, COORDS_CLICK.y5); - await page.mouse.click(COORDS_CLICK.x6, COORDS_CLICK.y6); + await clickOnCanvas(page, COORDS_CLICK.x2, COORDS_CLICK.y2); + await clickOnCanvas(page, COORDS_CLICK.x3, COORDS_CLICK.y3); + await clickOnCanvas(page, COORDS_CLICK.x1, COORDS_CLICK.y1); + await clickOnCanvas(page, COORDS_CLICK.x4, COORDS_CLICK.y4); + await clickOnCanvas(page, COORDS_CLICK.x5, COORDS_CLICK.y5); + await clickOnCanvas(page, COORDS_CLICK.x6, COORDS_CLICK.y6); } export async function fillFieldByLabel(