-3

I automate UI tests in python. I'm using pyqt and qtest. How handle QMessageBox and close it in unittest.

KanekiSenpai
  • 122
  • 10

1 Answers1

-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