I tried applying this using ChatGPT, but it didn't work for me. Can you tell me where to put this code to make my code work?
// Функция для эмуляции нажатия мыши внутри элемента <canvas data-sentry-element="Stage"> function simulateMouseClickInCanvas() { const canvas = document.querySelector('canvas[data-sentry-element="Stage"]'); if (!canvas) { console.error("Элемент <canvas> не найден."); return; } const rect = canvas.getBoundingClientRect(); // Выбираем случайные координаты внутри элемента <canvas> const randomX = Math.random() * rect.width + rect.left; const randomY = Math.random() * rect.height + rect.top; // Создаём события мыши const mouseDownEvent = new MouseEvent("mousedown", { bubbles: true, cancelable: true, clientX: randomX, clientY: randomY, }); const mouseUpEvent = new MouseEvent("mouseup", { bubbles: true, cancelable: true, clientX: randomX, clientY: randomY, }); const clickEvent = new MouseEvent("click", { bubbles: true, cancelable: true, clientX: randomX, clientY: randomY, }); // Эмулируем события canvas.dispatchEvent(mouseDownEvent); canvas.dispatchEvent(mouseUpEvent); canvas.dispatchEvent(clickEvent); } // Функция для выполнения кликов с рандомной задержкой function performRandomClicksInCanvas(maxClicks) { let clicksCount = 0; function clickWithRandomDelay() { if (clicksCount >= maxClicks) { console.log("Все клики выполнены"); return; } const delay = Math.random() * (2000 - 100) + 100; // Рандомная задержка от 0.1 до 2 секунд setTimeout(() => { simulateMouseClickInCanvas(); clicksCount++; console.log(`Клик ${clicksCount} выполнен (задержка: ${Math.round(delay)} мс)`); clickWithRandomDelay(); // Рекурсивный вызов для следующего клика }, delay); } clickWithRandomDelay(); } // Запуск выполнения 10 кликов performRandomClicksInCanvas(10);Script in record mode working but not in working in thread mode
-
Hello
I need the masters mind tonight.
I have a script which connect on few bank accounts and download the operations from the beginning of the month to the date and print them on a secure computer everyday at 00:01 amThe script is working fine on record mode especially where it has to tick a case for selecting the account number.
But as soon i test it on thread mode, it can not find the case to tick.I have struggled few days but no way.
BAS version is 22.3.2 (please do not ask me to change version, why working on record mode and not working on the other)
-
@HNB said in Script in record mode working but not in working in thread mode:
BAS version is 22.3.2 (please do not ask me to change version, why working on record mode and not working on the other)
maybe 23.2.2?
-
@HNB said in Script in record mode working but not in working in thread mode:
@Fox
Thanks
it will take me nearly 1 week to rewrite the script in new version :(Why?
-
@HNB said in Script in record mode working but not in working in thread mode:
But as soon i test it on thread mode, it can not find the case to tick.
Add waiting for the element, most likely the page does not have time to load. (for the test, set the "sleep" action for 10 seconds)
-
@DoctorKrolic
Yes i have used it.