Robot Framework
Dialogs.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 
27 
28 from robot.version import get_version
29 from robot.utils import is_truthy
30 
31 from .dialogs_py import (InputDialog, MessageDialog, MultipleSelectionDialog,
32  PassFailDialog, SelectionDialog)
33 
34 
35 __version__ = get_version()
36 __all__ = ['execute_manual_step', 'get_value_from_user',
37  'get_selection_from_user', 'pause_execution', 'get_selections_from_user']
38 
39 
40 
44 def pause_execution(message='Execution paused. Press OK to continue.'):
45  MessageDialog(message).show()
46 
47 
48 
57 def execute_manual_step(message, default_error=''):
58  if not _validate_user_input(PassFailDialog(message)):
59  msg = get_value_from_user('Give error message:', default_error)
60  raise AssertionError(msg)
61 
62 
63 
81 def get_value_from_user(message, default_value='', hidden=False):
82  return _validate_user_input(InputDialog(message, default_value,
83  is_truthy(hidden)))
84 
85 
86 
96 def get_selection_from_user(message, *values):
97  return _validate_user_input(SelectionDialog(message, values))
98 
99 
100 
112 def get_selections_from_user(message, *values):
113  return _validate_user_input(MultipleSelectionDialog(message, values))
114 
115 
117  value = dialog.show()
118  if value is None:
119  raise RuntimeError('No value provided by user.')
120  return value
def get_selection_from_user(message, *values)
Pauses execution and asks user to select a value.
Definition: Dialogs.py:96
def get_value_from_user(message, default_value='', hidden=False)
Pauses execution and asks user to input a value.
Definition: Dialogs.py:81
def _validate_user_input(dialog)
Definition: Dialogs.py:116
def execute_manual_step(message, default_error='')
Pauses execution until user sets the keyword status.
Definition: Dialogs.py:57
def get_selections_from_user(message, *values)
Pauses execution and asks user to select multiple values.
Definition: Dialogs.py:112
def pause_execution(message='Execution paused. Press OK to continue.')
Pauses execution until user clicks Ok button.
Definition: Dialogs.py:44
def is_truthy(item)
Returns True or False depending on is the item considered true or not.
Definition: robottypes.py:162
def get_version(naked=False)
Definition: version.py:24