ghost-cursor
ghost-cursor copied to clipboard
Problem with rounded buttons
When the button is a circle or has rounded box the click may happen to be outside the button. There is needed a better solution to handle rounded shapes otherwise clicks wont work.
Can you share the example from a webpage or component?
Sure. Just create a round button and try to click it.
const GhostCursor = require("ghost-cursor");
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage()
const cursor = GhostCursor.createCursor(page);
await GhostCursor.installMouseHelper(page);
//await page.goto('https://example.com/');
await page.reload();
await page.evaluate(() => {
let h = `
<div id="missedCount">Missed count: <b>0</b></div>
<div id="btn">Click me</div>
<style> #btn {border-radius: 93% 7% 96% 4% / 93% 6% 94% 7%; padding: 30px; background: #ffdcdc} </style>`;
let s = document.createElement('div'); s.innerHTML = h; document.body.appendChild(s);
});
await page.evaluate(() => {
let h = `
let missed = 0;
document.body.addEventListener('click', () => { missed++; updateCount(); });
document.querySelector('#btn').addEventListener('click', (e) => { e.stopImmediatePropagation(); });
function updateCount() { document.querySelector('#missedCount b').innerText = missed; }`;
let s = document.createElement('script'); s.innerHTML = h; document.body.appendChild(s);
});
while (true) {
let $btn = await page.$('#btn');
await cursor.click($btn).catch(console.error);
}
})();
A solution could be checking if the element hovered is actually our target, and if not retry.
document.elementFromPoint(e.clientX, e.clientY)
also having this issue
same
same issue
Any update on this issue? Facing same challenge