Closed Arinomo closed 2 years ago
Not sure why that does not work. Possibly you need to first clear the current text? Otherwise it is writing tho
.
However, in general I suggest to just call the appropriate methods in the widgets instead of trying to emulate the exact user actions. For example instead of trying to type text into a combo box to select an item, just call combo.setCurrentText
to select the desired item. This will call the appropriate signals, and then we can ensure our application is handling it appropriately.
We don't need to test ourselves that actually clicking on a combo box (or typing text on it) will behave as we expect, we can assume Qt itself is tested and works. Trying to emulate exactly the same events as an user would is hard to write, maintain, and makes for brittle tests.
Closing this for now, feel free to follow up with further questions.
I have following example
simple.py
and a test file
test_simple.py
that always failed at
test_combo_2
because it seems the second key clicksqtbot.keyClicks(app.combo, 'o')
does not do anything to the combo box.is there a way to test each item in combo box?