Note: To learn how to simulate user actions over button controls in web applications, see Working With Button Controls in Web Applications.
Before clicking a button, you may need to know whether it is enabled or not. If the button is disabled, an error will occur in your test.
While testing button controls, you can use specific properties and methods of the corresponding program object to perform certain actions and obtain data stored in controls. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with the needed properties and methods from your scripts. However, when testing a control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.
You can use the properties and methods of the
Win32Button object to get information about the current button control. The
Enabled property allows you to determine whether the current button control accepts user input. If the button is enabled, this property returns True; otherwise, False. The following example demonstrates how to check the button state:
Log.Message("The button is disabled.");
... if MyButton.Enabled: MyButton.Click() else: Log.Message("The button is disabled.") ...
If MyButton.Enabled Then
Log.Message("The button is disabled.")
if MyButton.Enabled then
Log.Message('The button is disabled.');
Log["Message"]("The button is disabled.");