pytestpytest-qt

How to make qtbot select an item from QComboBox?


I'm trying to develop a simple test application (using pytest) that tests an interface with many PyQt5 components (QLabel, QLineEdit, QCheckBox, QRadioButton and QComboBox), but I'm struggling with the combobox one.

How can I click on a QComboBox item using qtbot.mouseClick?

Here's what my QComboBox section looks like.

self.comboBox = QtWidgets.QComboBox(Form)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("ONE")
self.comboBox.addItem("TWO")
self.comboBox.addItem("THREE")

Solution

  • qtbot.keyClicks(self.comboBox, "ONE")