I automate UI tests in python. I'm using pyqt and qtest. How handle QMessageBox and close it in unittest.
Asked
Active
Viewed 137 times
1 Answers
-1
Start timer which will looking for active modal widget in app and close it.
def test_test(self):
[...]
# app = QApplication object
# ui = QWidget object
qTimer = QTimer(ui)
qTimer.timeout.connect(handleQMessageBox)
qTimer.start(100)
QTest.mouseClick(oneGrButton, QtCore.Qt.LeftButton) # -> this will call QMessageBox
def handleQMessageBox():
widget = app.activeModalWidget()
print(widget.text())
widget.close()

KanekiSenpai
- 122
- 10