| 1 |
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 2 |
# |
| 3 |
# Copyright (C) 2016 Canonical Ltd. |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU Lesser General Public License as published by |
| 7 |
# the Free Software Foundation; version 3. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU Lesser General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU Lesser General Public License |
| 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
import logging |
| 18 |
|
| 19 |
from autopilot import logging as autopilot_logging |
| 20 |
from lomiriuitoolkit._custom_proxy_objects import _common |
| 21 |
|
| 22 |
|
| 23 |
logger = logging.getLogger(__name__) |
| 24 |
|
| 25 |
|
| 26 |
class Sections(_common.LomiriUIToolkitCustomProxyObjectBase): |
| 27 |
"""Sections Autopilot custom proxy object.""" |
| 28 |
|
| 29 |
def __init__(self, *args): |
| 30 |
super().__init__(*args) |
| 31 |
self.listview = self.select_single(objectName='sections_listview') |
| 32 |
|
| 33 |
@autopilot_logging.log_action(logger.info) |
| 34 |
def click_section_button(self, section_index): |
| 35 |
"""Click a section button of the Sections. |
| 36 |
|
| 37 |
:parameter section_index: The index of the section to click. |
| 38 |
:raise ToolkitException: If there is no section button with that index. |
| 39 |
|
| 40 |
""" |
| 41 |
button_object_name = 'section_button_' + str(section_index) |
| 42 |
try: |
| 43 |
self.listview.click_element(button_object_name) |
| 44 |
except _common.ToolkitException: |
| 45 |
raise _common.ToolkitException( |
| 46 |
'Button with section index ' + str(section_index) + |
| 47 |
' not found in Sections.') |