reaz1995 / ghost-cursor-playwright

Modification of actual ghost-cursor for puppeteer, with more functionality and rewrited to work well with playwight.
49 stars 17 forks source link

TypeError: Cannot read properties of undefined (reading 'isEqualNode') #16

Open galaczi opened 3 hours ago

galaczi commented 3 hours ago

Hi, I am trying to click a button:

await cursor.actions.click({target: '#button', waitBeforeClick: [800, 3500]})

And getting this error:

TypeError: Cannot read properties of undefined (reading 'isEqualNode')
    at eval (eval at evaluate (:226:30), <anonymous>:4:42)
    at UtilityScript.evaluate (<anonymous>:228:17)
    at UtilityScript.<anonymous> (<anonymous>:1:44)

Any idea why that happens?

reaz1995 commented 2 hours ago

probably your target is undefined as the error states

galaczi commented 2 hours ago

It shouldn't be undefined. Playwright's page.fill finds it. cursor.getElemBoundingBox also finds it.

I can click with:

    const button = await cursor.getRandomPointInsideElem(await cursor.getElemBoundingBox('#button'))
    await page.mouse.click(button.x, button.y)
reaz1995 commented 2 hours ago

does await cursor.actions.move and await cursor.actions.click throw undefined?

galaczi commented 2 hours ago

cursor.actions.move does not throw, only cursor.actions.click. Same selector.

reaz1995 commented 2 hours ago

ok try find path of the element you target -> inspector aim it then press Copy JS path, paste that path in curosr.actions.click target and let me know if that works

galaczi commented 1 hour ago

You mean without document.querySelector, right? That wouldn't be a valid value for target. Yes, I have copied the selector from the browser as you suggested all along. It is found by playwright's locators, so it's definitely there. Maybe some kind of visibility or actionability test is the issue? locator.click() works though, so I don't think that should be an issue.

reaz1995 commented 1 hour ago

Check out the example in repo and see if you doesn't miss anything. I messed around with the code now but everything works as intended. The thing that throws you error is: image write in the spawned page console

 window['mouseTarget']

this cant be undefined