Entry point to communicate with a libFunq server : FunqClient
A FunqClient instance is generally retrieved with
funq.testcase.FunqTestcase.funq or
funq.testcase.MultiFunqTestcase.funq.
Example:
from funq.testcase import FunqTestCase
class MyTestCase(FunqTestCase):
__app_config_name__ = 'my_conf'
def test_something(self):
"""Method documentation"""
my_widget = self.funq.widget('mon_widget')
my_widget.click()
self.funq.take_screenshot()
-
class funq.client.FunqClient(host=None, port=None, aliases=None, timeout_connection=10)[source]
Allow to communicate with a libFunq server.
This is the main class used to manipulate tested application.
-
widget(alias=None, path=None, timeout=10.0, timeout_interval=0.1, wait_active=True)[source]
Returns an instance of a funq.models.Widget or derived
identified with an alias or with its complete path.
Example:
widget = client.widget('my_alias')
Parameters: |
- alias – alias defined in the aliases file.
- path – complete path for the widget
- timeout – if > 0, tries to get the widget until timeout
is reached (second)
- timeout_interval – time between two atempts to get a widget
(seconds)
- wait_active – If true - the default -, wait until the widget
become visible and enabled.
|
-
active_widget(widget_type='window', timeout=10.0, timeout_interval=0.1, wait_active=True)[source]
Returns an instance of a funq.models.Widget or derived
that is the active widget of the application, or the widget that
got the focus.
Be careful, this method acts weidly under Xvfb.
Example:
my_dialog = client.active_window('modal')
Parameters: |
- widget_type – kind of widget. (‘window’, ‘modal’, ‘popup’
ou ‘focus’
-> see the QT documentation about
QApplication::activeWindow,
QApplication::activeModalWidget,
QApplication::activePopupWidget or
QApplication::focusWidget respectively)
- timeout – if > 0, tries to get the widget until timeout
is reached (second)
- timeout_interval – time between two atempts to get a widget
(seconds)
- wait_active – If true - the default -, wait until the widget
become visible and enabled.
|
-
widgets_list(with_properties=False)[source]
Returns a dict with every widgets in the application.
-
dump_widgets_list(stream='widgets_list.json', with_properties=False)[source]
Write in a file the result of widgets_list().
-
take_screenshot(stream='screenshot.png', format_='PNG')[source]
Take a screenshot of the active desktop.
-
keyclick(text)[source]
Simulate keyboard entry by sending keypress and keyrelease events
for each character of the given text.
-
shortcut(key_sequence)[source]
Send a shortcut defined with a text sequence. The format of this
text sequence is defined with QKeySequence::fromString (see QT
documentation for more details).
Example:
-
drag_n_drop(src_widget, src_pos=None, dest_widget=None, dest_pos=None)[source]
Do a drag and drop.
Parameters: |
- src_widget – source widget
- src_pos – starting position for the drag. If None, the center
of src_widget will be used, else it must be a
tuple (x, y) in widget coordinates.
- dest_widget – destination widget. If None, src_widget will
be used.
- dest_pos – ending position for the drop. If None, the center
of dest_widget will be used, else it must be a
tuple (x, y) in widget coordinates.
|
-
duplicate()[source]
Allow to manipulate the application in another thread.
Returns a new instance of FunqClient with a new socket.
Example:
# `client_copy` may be used in concurrence with `client`.
client_copy = client.duplicate()