Mouse click by coordenates

info2000

Client
Регистрация
12.02.2012
Сообщения
42
Благодарностей
1
Баллы
8
I have the x,y coordinates of a element from the top of the screen with this command document.querySelector('.wgdt_banner').getBoundingClientRect()
but when I use these coordinates, the click only works 15% of the times with +/- 100px far of the element
How can I adjust to click exactly on the element?

Thanks
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 218
Благодарностей
5 843
Баллы
113
I would advise you to get topInTab , leftInTab coordinates of an element, as well as its width, height
Then use mouseclick -> topintab+height/2, leftinTab+width/2;
 
  • Спасибо
Реакции: info2000

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 218
Благодарностей
5 843
Баллы
113
You can also use FullMouseEmulation via C#:
C#:
instance.ActiveTab.FullEmulationMouseMoveToHtmlElement(likeButton);
instance.ActiveTab.FullEmulationMouseClick("left", "click");
 
  • Спасибо
Реакции: info2000

info2000

Client
Регистрация
12.02.2012
Сообщения
42
Благодарностей
1
Баллы
8
VladZen awesome answers both works well
 
  • Спасибо
Реакции: VladZen

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)