Waiting for UI Elements

As was already mentioned, KeePass is not only able to work with local databases but also with databases stored on a FTP server.

KeePass application opening a new database from a URL

KeePass application opening a new database from a URL

Depending on the speed of the internet connection and on the size of the database, the action of loading a database from a FTP server can take up to 10 seconds. After the download has finished, the log in dialog appears. To handle a scenario like that in Ranorex Recorder (or in the repository), every repository item has its own specific timeout value. Use the context menu item 'Properties' to open the properties for the application folder for the 'Log In' dialog.

Open properties of 'LoginWindow' application folder

Open properties of 'LoginWindow' application folder

In order to see what happens when the timeout value does not match the situation, set the dialog's search timeout to 10 milliseconds in order to force an error when executing the test case again. Even without loading the database from the external data store (e.g. FTP server) it takes some time to open the file and to bring up the dialog. A timeout of 10 milliseconds is not enough and the 'LogIn' recording module fails.
Test case execution failed - 'LoginWindow' was not found within the specified timeout of 10ms

Test case execution failed - 'LoginWindow' was not found within the specified timeout of 10ms

Note In order to restore your repository into a working condition, reset the search timeout value for the login dialog to 30 seconds.

Waiting for a Particular UI Element State using the WaitFor Action

It's often necessary or sensible to wait for the state of a UI item (e.g. its text) to change during test execution. You can easily accomplish this using the WaitFor action. Consider the following case in KeePass:

KeePass provides the functionality to copy a username or a password to the clipboard in a time limited manner (12 seconds by default). During that time, the status text in the application changes indicating that confidential information is kept in the clipboard. After 12 seconds the clipboard is cleared of the information; this is indicated by the status text 'Ready'. You can use the WaitFor action to wait until this text state changes to 'Ready'.

To demonstrate the functionality the WaitFor action, create a new test case (e.g. 'ClipBoardTestCase') containing the recording modules 'StartSUT', 'Login', 'SaveDB', and 'CloseSUT'. Now add two more recording modules after 'Login'.

Insert a new recording module after the 'LogIn' recording

Insert two new recording modules after the 'LogIn' recording

Name the first module 'CopyPassword' and record the procedure of right-clicking on an entry in KeePass and clicking 'Copy Password'.

Name the second module 'WaitForReady' and follow these steps to add the required actions to the recording:

  1. Confirm that KeePass is in a suitable state (opened, logged in, containing at least one entry).
  2. Open the recording module and click the 'Track...' button.
  3. Select the status text 'Ready.' at the bottom of the KeePass application. A repository item will be created and automatically selected.
  4. Drag this repository item to the action table and from the context menu that appears, select 'Wait For'.
  5. Select 'AttributeEqual' from the drop-down menu in the third column.
  6. Select 'Text' from the drop-down menu in the 'Match Name' column.
  7. Click on the action and press F4 to bring up its properties.
  8. Set the WaitTimeout to 13 seconds. We know that KeePass takes 12 seconds to remove the password from the clipboard, so that's the time we need to wait.

You can now run the test and you will see that Ranorex waits 13 seconds after the CopyPassword module to validate that the text in the status bar is 'Ready.'.