I want to simulate mouse Event in my Qt WebEngine app.
I use PyQt5.8 , QT5.8.
This is my code:
def mouse_click(self, x, y):
point = QPoint(int(x),
int(y))
eventp = QMouseEvent(QMouseEvent.MouseButtonPress,point,Qt.LeftButton,Qt.LeftButton,Qt.NoModifier)
self.sendEvent(eventp)
eventp = QMouseEvent(QMouseEvent.MouseButtonRelease,point,Qt.LeftButton,Qt.LeftButton,Qt.NoModifier)
self.sendEvent(eventp)
def sendEvent(self, event):
recipient = self.webpage.view().focusProxy()
recipient.grabKeyboard()
self.application.sendEvent(recipient, event)
recipient.releaseKeyboard()
I test it, but it does not worked. I can confirm mouse cursor on the element, but no mouse click event happend. Can anyone help me?
I use Mac OS 10.12.4, I test it using another demo, I find I can not catch Mouse Event, but I can catch other events. Any suggestions?