How to simulate clicking using dotnetbrowser on an element that doesn't have the "onclick" tag, only "event-action"
Asked
Active
Viewed 355 times
2
-
Where is your code and what have you tried? – Pavel Anikhouski Sep 17 '20 at 13:45
1 Answers
0
you can make so:
browser.MainFrame.Document.GetElementById("x123").Click();
if need click in element where id=x123
if it`s no work with element, you can send MouseClick to element Point:
int top = browser.MainFrame.Document.GetElementById("x123").BoundingClientRect.Origin.Y;
int left = browser.MainFrame.Document.GetElementById("x123").BoundingClientRect.Origin.X;
IMouse mouse = browser.Mouse;
MouseButton mouseButton = MouseButton.Left;
Point location = new Point(left+3, top+3);
MouseMovedEventArgs moveEvent = new MouseMovedEventArgs
{
Location = location
};
MousePressedEventArgs pressEvent = new MousePressedEventArgs
{
Location = location,
Button = mouseButton,
ClickCount = 1
};
MouseReleasedEventArgs releaseEvent = new MouseReleasedEventArgs
{
Button = mouseButton,
ClickCount = 1,
Location = location
};
mouse.Moved.Raise(moveEvent);
Thread.Sleep(200);
mouse.Pressed.Raise(pressEvent);
Thread.Sleep(200);
mouse.Released.Raise(releaseEvent);

Архипов Владимир
- 183
- 1
- 8