Squish/Waiting for Input from the Test Operator: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
m (style)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Delete|reason=Page not category. Include as single block in [[Squish: waiting for input from the test operator]] if relevant}}
[[Category:Squish]]
[[Category:Tools::Squish]]
 
= Waiting for input from the test operator =


In the cases where Squish cannot automate the whole test case, such as when a coin needs to be inserted into a slot machine or a physical button needs to be pressed which Squish cannot simulate, you need some way of notifying the test operator. As we have access to the whole Qt API from Squish, this can easily be done with a QMessageBox:
In the cases where Squish cannot automate the whole test case, such as when a coin needs to be inserted into a slot machine or a physical button needs to be pressed which Squish cannot simulate, you need some way of notifying the test operator. As we have access to the whole Qt API from Squish, this can easily be done with a QMessageBox:
<code>QMessageBox.information(0, "Input needed", "Please insert coin now!")<code>
<code>
QMessageBox.information(0, "Input needed", "Please insert coin now!")
</code>


As the call to information() won't return until the user clicks the OK button, the script will be paused until that happens.
As the call to information() won't return until the user clicks the OK button, the script will be paused until that happens.


We can also use Squish's powerful waitFor() command to continue the script immediately when the required action has occurred, without the user having to click a button, which can be useful in situations where an input cursor is not available for the test operator:
We can also use Squish's powerful waitFor() command to continue the script immediately when the required action has occurred, without the user having to click a button, which can be useful in situations where an input cursor is not available for the test operator:
</code>label = QLabel("Please insert coin now!")
<code>
label = QLabel("Please insert coin now!")
label.show()
label.show()
waitFor("findObject(':CoinCounter_QLabel').text == '1'")
waitFor("findObject(':CoinCounter_QLabel').text == '1'")
label.close()<code>
label.close()
</code>

Latest revision as of 10:46, 11 August 2020


In the cases where Squish cannot automate the whole test case, such as when a coin needs to be inserted into a slot machine or a physical button needs to be pressed which Squish cannot simulate, you need some way of notifying the test operator. As we have access to the whole Qt API from Squish, this can easily be done with a QMessageBox:

QMessageBox.information(0, "Input needed", "Please insert coin now!")

As the call to information() won't return until the user clicks the OK button, the script will be paused until that happens.

We can also use Squish's powerful waitFor() command to continue the script immediately when the required action has occurred, without the user having to click a button, which can be useful in situations where an input cursor is not available for the test operator:

label = QLabel("Please insert coin now!")
label.show()
waitFor("findObject(':CoinCounter_QLabel').text == '1'")
label.close()