how to send click events to yandex smartcaptcha img

gsp

New member
Hello, i'm trying to solve captcha in yandex search (https://yandex.ru/search?text=123). I'm stuck at the stage of clicking on the captcha image. My click attempts don't result in marks appearing on the image.

var el = document.getElementsByClassName('AdvancedCaptcha-ImageWrapper')[0].firstChild;

var rect = el.getBoundingClientRect();
var x = rect.right - rect.left / 2;
var y = rect.bottom - rect.top / 2;

var ev = new MouseEvent('click', {
view: window,
bubbles: true,
cancelable: true,
offsetX: x,
offsetY: y
});

el.dispatchEvent(ev);

I tried target on different html elements, tried PointerEvent. Sent events are visible in the debugger, and the same events allow you to click on a button, but the events do not lead to the appearance of marks on the image.
Please any comments?
 

Attachments

  • Screenshot_4.png
    Screenshot_4.png
    287.5 KB · Views: 1

Bronya

Member
Hi there, Try to use this


The calculation for the x and y coordinates seems to be incorrect. The x and y values are meant to represent the coordinates where the click event will be dispatched. The current calculation takes the rect.right and rect.bottom values and subtracts half the width and half the height of the element, respectively. However, the parentheses are not correctly placed, which causes the division by 2 to only apply to rect.left and rect.top, not to the entire width and height as intended.

The corrected calculation should be:

Code:
var x = (rect.right - rect.left) / 2;
var y = (rect.bottom - rect.top) / 2;

I hope it help