class ExternalRSSFeed(object): """This element encapsulates selection of an external RSS source either from canned selection or custom one. It expects a :py:class:`str` filling object. If the string is not found in the dropdown, it is considered to be custom url, so it selects custom URL option in the dropdown and fills the text input with the URL. If the option is available in the dropdown, then it is selected. """ form = Region(locators=dict(rss_url=Select("//select[@id='rss_url']"), txt_url="//input[@id='txt_url']"))
# -*- coding: utf-8 -*- from contextlib import contextmanager from cfme.exceptions import RequestException from cfme.fixtures import pytest_selenium as sel from cfme.web_ui import Input, Region, SplitTable, Table, fill, flash, paginator, toolbar from utils import version from utils.log import logger REQUEST_FINISHED_STATES = {'Migrated', 'Finished'} buttons = Region( locators=dict( approve="//*[@title='Approve this Request']/img", deny="//*[@title='Deny this Request']/img", copy="//*[@title='Copy original Request']/img", edit="//*[@title='Edit the original Request']/img", delete="//*[@title='Delete this Request']/img", submit="//span[@id='buttons_on']/a[@title='Submit']", cancel="//a[@title='Cancel']", ) ) fields = Region( locators=dict( reason=Input("reason"), request_list={ version.LOWEST: SplitTable( ('//*[@id="list_grid"]//table[contains(@class, "hdr")]/tbody', 1), ('//*[@id="list_grid"]//table[contains(@class, "obj")]/tbody', 1)), "5.5.0.8": Table('//*[@id="list_grid"]/table'),
Input('url')), ('ssl_checkbox', Input('verify_ssl'))]) credential_form = Form( fields=[('principal_text', Input('log_userid')), ('secret_pass', Input('log_password')), ('verify_secret_pass', Input('log_verify')), ('validate_btn', form_buttons.validate)]) def cfm_mgr_table(): return Table("//div[@id='main_div']//div[@id='list_grid']/table") page = Region( locators={ 'list_table_config_profiles': cfm_mgr_table(), 'list_table_config_systems': cfm_mgr_table() }) add_manager_btn = form_buttons.FormButton('Add') edit_manager_btn = form_buttons.FormButton('Save changes') cfg_btn = partial(tb.select, 'Configuration') match_page = partial(match_location, controller='provider_foreman', title='Red Hat Satellite Provider') class ConfigManager(Updateable, Pretty, Navigatable): """ This is base class for Configuration manager objects (Red Hat Satellite, Foreman, Ansible Tower)
(i.e. when service is either `sat5` or `sat6`). """ def make_update_button(text): return "//div[@id='settings_rhn']//button[normalize-space(.)='{}']".format( text) update_buttons = Region(locators={ 'edit_registration': make_update_button("Edit Registration"), 'refresh': make_update_button("Refresh List"), 'check_updates': make_update_button("Check for Updates"), 'register': make_update_button("Register"), 'apply_updates': make_update_button("Apply CFME Update") }, identifying_loc="edit_registration") registration_form = Form(fields=[ ("service", Select("//select[@id='register_to']")), ("url", Input('server_url')), ("repo_name", Input('repo_name')), ("use_proxy", Input('use_proxy')), ("proxy_url", Input('proxy_address')), ("proxy_username", Input('proxy_userid')), ("proxy_password", Input('proxy_password')),
# -*- coding: utf-8 -*- from cfme import web_ui as ui from cfme.fixtures import pytest_selenium as sel from cfme.web_ui import Region, accordion, fill, flash, form_buttons from cfme.web_ui.menu import nav nav.add_branch( "reports", { "import_export": lambda ctx: accordion.tree("Import/Export", "Import / Export"), }) form = Region(locators=dict( export_select=ui.Select("//select[@id='choices_chosen']", multi=True), export_button=form_buttons.FormButton("Download Report to YAML"), import_overwrite=ui.Input('overwrite'), import_file=ui.Input('upload_file'), import_submit=ui.Input('upload_atags'))) export_select = ui.Select("//select[@id='choices_chosen']", multi=True) export_button = form_buttons.FormButton("Download Report to YAML") def export_reports(*custom_report_names): sel.force_navigate("import_export") fill(form.export_select, custom_report_names) sel.click(form.export_button) def import_reports(filename, overwrite=False): sel.force_navigate("import_export")
class Class(TreeNode, Updateable): """Represents a Class in the CFME ui. `Display Name` is not supported (it causes the name to be displayed differently in different places in the UI).""" form = Form(fields=[('name_text', "//input[@name='name']"), ('display_name_text', "//input[@name='display_name']"), ('description_text', "//input[@name='description']"), ('inherits_from_select', Select("//select[@name='inherits_from']"))] + submit_and_cancel_buttons) def __init__(self, name=None, display_name=None, description=None, inherits_from=None, namespace=None): self.name = name # self.display_name = display_name self.description = description self.inherits_from = inherits_from self.namespace = namespace @property def parent(self): return self.namespace def path_str(self): """Returns string path to this class, eg ns1/ns2/ThisClass""" return "/".join(self.path) def create(self, cancel=False): sel.force_navigate("automate_explorer_class_new", context={"tree_item": self.namespace}) fill( self.form, { 'name_text': self.name, 'description_text': self.description, # 'display_name_text': self.display_name, 'inherits_from_select': self.inherits_from and self.inherits_from.path_str() }, action={ True: self.form.cancel_btn, False: self.form.add_btn }[cancel]) try: flash.assert_success_message('Automate Class "%s" was added' % self.path_str()) except Exception as e: if error.match("Name has already been taken", e): sel.click(self.form.cancel_btn) raise def update(self, updates, cancel=False): sel.force_navigate("automate_explorer_edit", context={ "tree_item": self.parent, "table_item": self }) fill( self.form, { 'name_text': updates.get('name'), 'description_text': updates.get('description'), # 'display_name_text': updates.get('display_name'), 'inherits_from_select': updates.get('inherits_from') and updates.get('inherits_from').path_str() }, action={ True: self.form.cancel_btn, False: self.form.save_btn }[cancel]) def delete(self, cancel=False): sel.force_navigate("automate_explorer_delete", context={ 'tree_item': self.parent, 'table_item': self }) sel.handle_alert(cancel) return flash.assert_no_errors() class SchemaField(Updateable): def __init__(self, name=None, type_=None, data_type=None, default_value=None, display_name=None, description=None, sub=None, collect=None, message=None, on_entry=None, on_exit=None, on_error=None, max_retries=None, max_time=None): self.name = name self.type_ = type_ self.data_type = data_type self.default_value = default_value self.display_name = display_name self.description = description self.sub = sub self.collect = collect self.message = message self.on_entry = on_entry self.on_exit = on_exit self.on_error = on_error self.max_retries = max_retries self.max_time = max_time def get_form(self, blank=False): """Gets a form for a field that already exists (by its name). Or if blank=True, get the form for a new field. Must be on the correct page before calling this. """ idx = "" if blank: row_id = "" # for new entries, id attribute has no trailing '_x' else: idx = sel.get_attribute( "//input[starts-with(@id, 'fields_name') and @value='%s']" % self.name, 'id').split("_")[2] row_id = "_" + idx def loc(fmt): if blank: plural = "" else: plural = "s" return fmt % (plural, row_id) def remove(loc): """Return a callable that clicks but still allows popup dismissal""" return lambda _: sel.click(loc, wait_ajax=False) return Form(fields=[ ('name_text', loc("//input[@id='field%s_name%s']")), ('type_select', DHTMLSelect(loc("//div[@id='field%s_aetype_id%s']"))), ('data_type_select', DHTMLSelect(loc("//div[@id='field%s_datatype_id%s']"))), ('default_value_text', loc("//input[@id='field%s_default_value%s']")), ('display_name_text', loc("//input[@id='field%s_display_name%s']")), ('description_text', loc("//input[@id='field%s_description%s']") ), ('sub_cb', loc("//input[@id='field%s_substitution%s']")), ('collect_text', loc("//input[@id='field%s_collect%s']") ), ('message_text', loc("//input[@id='field%s_message%s']")), ('on_entry_text', loc("//input[@id='field%s_on_entry%s']") ), ('on_exit_text', loc("//input[@id='field%s_on_exit%s']")), ('max_retries_text', loc("//input[@id='field%s_max_retries%s']") ), ('max_time_text', loc("//input[@id='field%s_max_time%s']") ), ('add_entry_button', "//img[@alt='Add this entry']"), ('remove_entry_button', remove("//a[contains(@title, 'delete this') " "and contains(@href, 'arr_id=%s')]/img" % idx)) ]) schema_edit_page = Region( locators=dict({'add_field_btn': "//img[@alt='Equal-green']"}.items() + submit_and_cancel_buttons)) def edit_schema(self, add_fields=None, remove_fields=None): sel.force_navigate("automate_explorer_schema_edit", context={'tree_item': self}) for remove_field in remove_fields or []: f = remove_field.get_form() fill(f, {}, action=f.remove_entry_button) sel.handle_alert() for add_field in add_fields or []: sel.click(self.schema_edit_page.add_field_btn) f = add_field.get_form(blank=True) fill(f, { 'name_text': add_field.name, 'type_select': add_field.type_, 'data_type_select': add_field.data_type, 'default_value_text': add_field.default_value, 'description_text': add_field.description, 'sub_cb': add_field.sub, 'collect_text': add_field.collect, 'message_text': add_field.message, 'on_entry_text': add_field.on_entry, 'on_exit_text': add_field.on_exit, 'max_retries_text': add_field.max_retries, 'max_time_text': add_field.max_time }, action=f.add_entry_button) sel.click(self.schema_edit_page.save_btn) flash.assert_success_message( 'Schema for Automate Class "%s" was saved' % self.name)
from utils import deferred_verpick, version from utils.appliance import Navigatable from utils.appliance.implementations.ui import navigator, CFMENavigateStep, navigate_to from utils.browser import ensure_browser_open from utils.pretty import Pretty from utils.varmeth import variable from utils.log import logger from utils.wait import wait_for paged_tbl = PagedTable(table_locator="//div[@id='list_grid']//table") cfg_btn = partial(tb.select, 'Configuration') mon_btn = partial(tb.select, 'Monitoring') pol_btn = partial(tb.select, 'Policy') details_page = Region(infoblock_type='detail') properties_form = Form(fields=[( 'type_select', AngularSelect('server_emstype')), ( 'name_text', Input('name')), ('hostname_text', Input('hostname')), ('port_text', Input('port'))]) properties_form_56 = TabStripForm( fields=[('type_select', AngularSelect('ems_type')), ('name_text', Input('name'))], tab_fields={ "Default": [ ('hostname_text', Input("default_hostname")), ('port_text', Input("default_api_port")),
from selenium.common.exceptions import NoSuchElementException import utils.conf as conf from utils.datafile import load_data_file from utils.log import logger from utils.path import project_path from utils.update import Updateable from utils.wait import wait_for from utils.pretty import Pretty from utils.db import cfmedb from utils.varmeth import variable cfg_btn = partial(tb.select, 'Configuration') pxe_server_table_exist = Table('//div[@id="records_div"]/table/tbody/tr/td') pxe_details_page = Region(locators=dict( last_refreshed=InfoBlock("Basic Information", "Last Refreshed On"), pxe_image_type=InfoBlock("Basic Information", "Type"))) pxe_properties_form = Form(fields=[ ('name_text', Input('name')), ('log_protocol', Select("//select[@id='log_protocol']")), ('uri_text', Input('uri')), ('userid_text', Input('log_userid')), ('password_text', Input('log_password')), ('verify_text', Input('log_verify')), ('validate_btn', "//a[@id='val']"), ('access_url_text', Input('access_url')), ('pxe_dir_text', Input('pxe_directory')), ('windows_dir_text', Input('windows_images_directory')), ('customize_dir_text', Input('customization_directory')), ('pxe_menu_text', Input('pxemenu_0')),
('verify_secret_pass', Input('log_verify')), ('validate_btn', form_buttons.validate) ]) CfgMgrSplitTable = lambda: SplitTable( header_data=("//div[@id='list_grid']/div[@class='xhdr']/table/tbody", 1), body_data=("//div[@id='list_grid']/div[@class='objbox']/table/tbody", 1),) CfgMgrTable = lambda: Table("//div[@id='main_div']//div[@id='list_grid']/table") page = Region(locators={ 'list_table_config_profiles': { version.LOWEST: CfgMgrSplitTable(), "5.5": CfgMgrTable()}, 'list_table_config_systems': { version.LOWEST: CfgMgrSplitTable(), "5.5": CfgMgrTable()}}) add_manager_btn = form_buttons.FormButton('Add') edit_manager_btn = form_buttons.FormButton('Save changes') cfg_btn = partial(tb.select, 'Configuration') nav.add_branch( 'infrastructure_config_management', { 'infrastructure_config_managers': [ lambda _: (accordion.tree('Providers', version.pick({version.LOWEST: 'All Red Hat Satellite Providers',
def _expressions_root(): return sel.element("./fieldset/div", root=_root()) ### # Buttons container buttons = Region(locators=dict( commit="//img[@alt='Commit expression element changes']", discard="//img[@alt='Discard expression element changes']", remove= "//span[not(contains(@style, 'none'))]//img[@alt='Remove this expression element']", NOT="//span[not(contains(@style, 'none'))]" + "//img[@alt='Wrap this expression element with a NOT']", OR= "//span[not(contains(@style, 'none'))]//img[@alt='OR with a new expression element']", AND= "//span[not(contains(@style, 'none'))]//img[@alt='AND with a new expression element']", redo="//img[@alt='Redo']", undo="//img[@alt='Undo']", select_specific= "//img[@alt='Click to change to a specific Date/Time format']", select_relative= "//img[@alt='Click to change to a relative Date/Time format']", )) ### # Buttons for operationg the expression concatenation # def click_undo(): sel.click(buttons.undo)
search_box = Region(locators=dict( # Filter of results, the search field that is normally visible search_field=Input("search_text", "search[text]"), # The icon buttons for searching search_icon={ "5.3": "//div[@id='searchbox']//*[@id='searchicon']", "5.4": "//div[@id='searchbox']//div[contains(@class, 'form-group')]" "/*[self::a or (self::button and @type='submit')]" }, # The arrow opening/closing the advanced search box toggle_advanced={ "5.3": "//img[@id='adv_search_img']", "5.4": "(//button | //a)[@id='adv_search']" }, # Container for the advanced search box advanced_search_box={ "5.3": "//div[@id='advsearchbox']", "5.4": "//div[@id='advsearchModal']//div[@class='modal-content']" }, # Buttons on main view apply_filter_button={ "5.3": "//a[@title='Apply the current filter']", "5.4": FormButton("Apply the current filter") }, load_filter_button={ "5.3": "//a[@title='Load a filter']", "5.4": FormButton("Load a filter") }, delete_filter_button={ "5.3": "//a[contains(@title, 'Delete the filter named')]", "5.4": FormButton("Delete the filter named", partial_alt=True) }, save_filter_button={ "5.3": "//a[@title='Save the current filter']", "5.4": FormButton("Save the current filter") }, reset_filter_button={ "5.3": "//a[@title='Reset the filter']", "5.4": FormButton("Reset the filter") }, close_button= "//div[@id='advsearchModal']/div//button/span[normalize-space(.)='×']", # Buttons in the "next step" load_filter_dialog_button={ "5.3": "//a[@title='Load the filter shown above']", "5.4": FormButton("Load the filter shown above") }, cancel_load_filter_dialog_button={ "5.3": "//a[@title='Cancel the load']", "5.4": FormButton("Cancel the load") }, save_filter_dialog_button={ "5.3": "//a[@title='Save the current search']", "5.4": FormButton("Save the current search") }, cancel_save_filter_dialog_button={ "5.3": "//a[@title='Cancel the save']", "5.4": FormButton("Cancel the save") }, # If user input requested, this window appears quick_search_box="//div[@id='quicksearchbox']", # With these buttons userinput_apply_filter_button={ "5.3": "//a[@id='apply_button']", "5.4": FormButton("Apply the current filter (Enter)") }, userinput_cancel_button={ "5.3": "//a[@title='Cancel (Esc)']", "5.4": FormButton("Cancel (Esc)") }, # Selects for selecting the filter saved_filter=Select("select#chosen_search"), report_filter=Select("select#chosen_report"), # Elements in Save dialog save_name=Input("search_name"), global_search=Input("search_type"), # On the main page, this link clears the filters clear_advanced_search="//a[contains(@href, 'adv_search_clear')]", ))
""" A page functions for Availability Zone :var list_page: A :py:class:`cfme.web_ui.Region` object describing elements on the list page. :var details_page: A :py:class:`cfme.web_ui.Region` object describing elements on the detail page. """ from cfme.web_ui import Region, SplitTable # Page specific locators list_page = Region(locators={ 'zone_table': SplitTable(header_data=('//div[@class="xhdr"]/table/tbody', 1), body_data=('//div[@class="objbox"]/table/tbody', 1)) }, title='Cloud Providers') details_page = Region(infoblock_type='detail')
import cfme.fixtures.pytest_selenium as sel from cfme.web_ui import Form, Region, Select, fill, flash from cfme.web_ui.form_buttons import FormButton import_form = Form( fields=[("file_select", "#upload_file"), ("upload_button", "//input[@id='upload_atags' or @id='upload_tags']")]) export_form = Form(fields=[ ("type", Select("select#dbtype")), ("available", Select("select#choices_chosen_")), ]) upload_buttons = Region(locators=dict( commit_button=FormButton("Commit Import"), cancel_button=FormButton("Cancel Import"), )) def import_file(filename, cancel=False): """ Go to Control / Import Export and import given file. Args: filename: Full path to file to import. cancel: Whether to click Cancel instead of commit. """ sel.force_navigate("control_import_export") fill( import_form, {"file_select": filename}, )
from cfme.web_ui import Form, Region, Select, CheckboxTable, fill, paginator from cfme.web_ui.menu import nav from utils.timeutil import parsetime from utils.wait import wait_for, TimedOutError nav.add_branch( "tasks", dict( tasks_my_vm=lambda _: tabs.select_tab("My VM Analysis Tasks"), tasks_my_other_ui=lambda _: tabs.select_tab("My Other UI Tasks"), tasks_all_vm=lambda _: tabs.select_tab("All VM Analysis Tasks"), tasks_all_other=lambda _: tabs.select_tab("All Other Tasks"), )) buttons = Region(locators=dict(default="//*[@id='buttons_off']/li[3]/a/img", apply="//*[@id='buttons_on']/li[1]/a/img", reset="//*[@id='buttons_on']/li[2]/a/img")) filter_form = Form(fields=[ ("zone", Select("//select[@id='chosen_zone']")), ("user", Select("//select[@id='user_choice']")), ("time_period", Select("//select[@id='time_period']")), ("task_status_queued", "//input[@id='queued']"), ("task_status_running", "//input[@id='running']"), ("task_status_ok", "//input[@id='ok']"), ("task_status_error", "//input[@id='error']"), ("task_status_warn", "//input[@id='warn']"), ("task_state", Select("//select[@id='state_choice']")), ]) tasks_table = CheckboxTable(
import cfme.web_ui.toolbar as tb from cfme.web_ui import fill, Region, Form, ScriptBox, Select, Table, form_buttons from cfme.web_ui import paginator as pg from selenium.common.exceptions import NoSuchElementException import utils.conf as conf from utils.datafile import load_data_file from utils.log import logger from utils.path import project_path from utils.update import Updateable from utils.wait import wait_for from utils import version cfg_btn = partial(tb.select, 'Configuration') pxe_server_table_exist = Table('//div[@id="records_div"]/table/tbody/tr/td') pxe_details_page = Region(infoblock_type='form') # infoblock shoudl be type 'detail' #gofigure pxe_properties_form = Form( fields=[ ('name_text', "//input[@id='name']"), ('log_protocol', Select("//select[@id='log_protocol']")), ('uri_text', "//input[@id='uri']"), ('userid_text', "//input[@id='log_userid']"), ('password_text', "//input[@id='log_password']"), ('verify_text', "//input[@id='log_verify']"), ('validate_btn', "//a[@id='val']"), ('access_url_text', "//input[@id='access_url']"), ('pxe_dir_text', "//input[@id='pxe_directory']"), ('windows_dir_text', "//input[@id='windows_images_directory']"), ('customize_dir_text', "//input[@id='customization_directory']"), ('pxe_menu_text', "//input[@id='pxemenu_0']"),
from cfme.web_ui import (accordion, fill, flash, paginator, toolbar, CheckboxTree, Region, Tree, Quadicon) from cfme.web_ui.menu import extend_nav from functools import partial from utils.api import rest_api from utils.wait import wait_for cfg_btn = partial(toolbar.select, 'Configuration') pwr_btn = partial(toolbar.select, 'Power') tree_inst_by_prov = partial(accordion.tree, "Instances by Provider") tree_instances = partial(accordion.tree, "Instances") tree_image_by_prov = partial(accordion.tree, "Images by Provider") tree_images = partial(accordion.tree, "Images") list_page = Region(title='Instances') policy_page = Region( locators={ 'policy_tree': Tree('//div[@class="containerTableStyle"]/table') }) manage_policies_tree = CheckboxTree("//div[@id='protect_treebox']/ul") @extend_nav class clouds_instances: def clouds_instances_by_provider(_): tree_inst_by_prov("Instances by Provider") def clouds_instances_provider_branch(ctx):
# -*- coding: utf-8 -*- """Module handling the Rails exceptions from CFME""" from cfme.exceptions import CFMEExceptionOccured from cfme.fixtures import pytest_selenium as sel from cfme.web_ui import Region cfme_exception_region = Region( locators=dict( root_div="//div[@id='exception_div']", error_text="//div[@id='exception_div']//td[@id='maincol']/div[2]/h3[2]", ), identifying_loc="root_div", ) def is_cfme_exception(): """Check whether an exception is displayed on the page""" return cfme_exception_region.is_displayed() def cfme_exception_text(): """Get the error message from the exception""" return sel.text(cfme_exception_region.error_text) def assert_no_cfme_exception(): """Raise an exception if CFME exception occured Raises: :py:class:`cfme.exceptions.CFMEExceptionOccured` """
from cfme.exceptions import RequestException from cfme.fixtures import pytest_selenium as sel from cfme.web_ui import (Input, Region, Table, fill, flash, paginator, toolbar, match_location) from utils.log import logger from utils.appliance import Navigatable from utils.appliance.implementations.ui import navigator, CFMENavigateStep, navigate_to REQUEST_FINISHED_STATES = {'Migrated', 'Finished'} buttons = Region(locators=dict( approve="//*[@title='Approve this Request']", deny="//*[@title='Deny this Request']", copy="//*[@title='Copy original Request']", edit="//*[@title='Edit the original Request']", delete="//*[@title='Delete this Request']", submit="//span[@id='buttons_on']/a[@title='Submit']", cancel="//a[@title='Cancel']", )) request_table = Table('//*[@id="list_grid"]/table') fields = Region( locators=dict(reason=Input("reason"), request_list=request_table)) match_page = partial(match_location, controller='miq_request', title='Requests') # TODO Refactor these module methods and their callers for a proper request class
import cfme.fixtures.pytest_selenium as sel from cfme.exceptions import CFMEExceptionOccured, FlashMessageException from cfme.web_ui import Region from utils import version from utils.log import logger from utils.pretty import Pretty area = Region( locators={ 'message': { version.LOWEST: ' | '.join([ ('//div[starts-with(@id, "flash_") and ' 'not(ancestor::*[contains(@style,"display: none")])]//li'), '//div[@id="flash_div"]', # login screen ]), '5.3': ' | '.join([ ('//div[starts-with(@id, "flash_") and ' 'not(ancestor::*[contains(@style,"display: none")])]' '//div[contains(@class,"alert")]'), '//div[@id="flash_div"]', # login screen ]) } }) _mapping_new = { "alert-warning": "warning", "alert-success": "success", "alert-danger": "error", "alert-info": "info" }
import cfme.fixtures.pytest_selenium as sel from cfme.base import Server from cfme.web_ui import Region, Table, tabstrip, toolbar from utils.timeutil import parsetime from utils.pretty import Pretty from utils.wait import wait_for from utils.appliance.implementations.ui import navigate_to from . import BaseLoggedInPage page = Region(title="Dashboard", locators={ 'reset_widgets_button': toolbar.root_loc('Reset Dashboard Widgets to the defaults'), 'csrf_token': "//meta[@name='csrf-token']", 'user_dropdown': '//nav//a[@id="dropdownMenu2"]', 'help_dropdown': '//nav//a[@id="dropdownMenu1"]' }, identifying_loc='reset_widgets_button') class DashboardView(BaseLoggedInPage): @property def is_displayed(self): return (self.logged_in_as_current_user and self.navigation.currently_selected == ['Cloud Intel', 'Dashboard'])
search_box = Region(locators=dict( # Filter of results, the search field that is normally visible search_field="//div[@id='searchbox']//input[@id='search_text']", # The icon buttons for searching search_icon="//div[@id='searchbox']//*[@id='searchicon']", # The arrow opening/closing the advanced search box toggle_advanced="//img[@id='adv_search_img']", # Container for the advanced search box advanced_search_box="//div[@id='advsearchbox']", # Buttons on main view apply_filter_button="//a[@title='Apply the current filter']", load_filter_button="//a[@title='Load a filter']", delete_filter_button="//a[contains(@title, 'Delete the filter named')]", save_filter_button="//a[@title='Save the current filter']", reset_filter_button="//a[@title='Reset the filter']", # Buttons in the "next step" load_filter_dialog_button="//a[@title='Load the filter shown above']", cancel_load_filter_dialog_button="//a[@title='Cancel the load']", save_filter_dialog_button="//a[@title='Save the current search']", cancel_save_filter_dialog_button="//a[@title='Cancel the save']", # If user input requested, this window appears quick_search_box="//div[@id='quicksearchbox']", # With these buttons userinput_apply_filter_button="//a[@id='apply_button']", userinput_cancel_button="//a[@title='Cancel (Esc)']", # Selects for selecting the filter saved_filter=Select("//select[@id='chosen_search']"), report_filter=Select("//select[@id='chosen_report']"), # Elements in Save dialog save_name="//input[@id='search_name']", global_search="//input[@id='search_type']", # On the main page, this link clears the filters clear_advanced_search="//a[contains(@href, 'adv_search_clear')]", ))
from cfme.web_ui import Region, Form, fill, Input from utils import conf, version from utils.browser import ensure_browser_open, quit from utils.log import logger from fixtures.pytest_store import store page = Region( # TODO: Make title defer it's resolution title={ version.LOWEST: "Dashboard", '5.5': "Login" }, locators={ 'username': Input("user_name"), 'password': Input("user_password"), 'submit_button': '//a[@id="login"]|//button[normalize-space(.)="Login"]/..', # Login page has an abnormal flash div 'flash': '//div[@id="flash_div"]', 'logout': '//a[contains(@href, "/logout")]', 'update_password': '******', 'back': '//a[@title="Back"]', 'user_new_password': Input("user_new_password"), 'user_verify_password': Input("user_verify_password") }, identifying_loc='submit_button') _form_fields = ('username', 'password', 'user_new_password', 'user_verify_password') form = Form( fields=[loc for loc in page.locators.items() if loc[0] in _form_fields], identifying_loc='username')
fields=[('type_select', AngularSelect('ems_type')), ('name_text', Input('name'))], tab_fields={ "Default": [ ('hostname_text', Input("default_hostname")), ('port_text', Input("default_api_port")), ('sec_protocol', AngularSelect("default_security_protocol")), ], "Hawkular": [('hawkular_hostname', Input("hawkular_hostname")), ('hawkular_api_port', Input("hawkular_api_port"))], }) prop_region = Region( locators={ 'properties_form': { version.LOWEST: properties_form, '5.6': properties_form_56, } }) class Provider(BaseProvider, Pretty): pretty_attrs = ['name', 'key', 'zone'] STATS_TO_MATCH = [ 'num_project', 'num_service', 'num_replication_controller', 'num_pod', 'num_node', 'num_container', 'num_image' ] # TODO add 'num_image_registry' and 'num_volume' string_name = "Containers" page_name = "containers" detail_page_suffix = 'provider_detail'
('add_entry_button', Input("accept")), # This one too? vvv I could not find it in the form ('field_category', Select("//select[@id='field_category']")), ('text_area', { version.LOWEST: Input("field_default_value"), "5.5": AngularSelect("field_default_value") }), ('dynamic_chkbox', Input("field_dynamic")), ('apply_btn', '//a[@title="Apply"]') ]) common = Region( locators={ "dialogs_table": { version.LOWEST: SplitTable(header_data=('//div[@class="xhdr"]/table/tbody', 1), body_data=('//div[@class="objbox"]/table/tbody', 1)), "5.5": Table("//div[@id='list_grid']/table") } }) def _all_servicedialogs_add_new(context): cfg_btn('Add a new Dialog') sel.wait_for_element(label_form.label) menu.nav.add_branch( 'automate_customization', { 'service_dialogs': [ lambda _: accordion.tree("Service Dialogs", "All Dialogs"), {
from widgetastic_manageiq import BootstrapSelect, Button, CheckboxSelect, Table from widgetastic_patternfly import Dropdown, Tab, FlashMessages from cfme import web_ui as ui from cfme.base.login import BaseLoggedInPage import cfme.fixtures.pytest_selenium as sel from cfme.web_ui import Form, Region, CheckboxTable, fill, match_location from utils.appliance import Navigatable from utils.appliance.implementations.ui import navigator, CFMENavigateStep, navigate_to from utils.log import logger from utils.wait import wait_for, TimedOutError from cfme.services import requests buttons = Region( locators={ 'default': '//*[@id="buttons_off"]/a', 'apply': '//*[@id="buttons_on"]/a[1]', 'reset': '//*[@id="buttons_on"]/a[2]' }) filter_form = Form(fields=[ ("zone", ui.Select("//select[@id='chosen_zone']")), ("user", ui.Select("//select[@id='user_choice']")), ("time_period", ui.Select("//select[@id='time_period']")), ("task_status_queued", ui.Input('queued')), ("task_status_running", ui.Input('running')), ("task_status_ok", ui.Input('ok')), ("task_status_error", ui.Input('error')), ("task_status_warn", ui.Input('warn')), ("task_state", ui.Select("//select[@id='state_choice']")), ])
QUADICON_TITLE_LOCATOR = ( "//div[@id='quadicon']/../../../tr/td/a[contains(@href,'vm_infra/x_show')" " or contains(@href, '/show/')]") cfg_btn = partial(toolbar.select, 'Configuration') pol_btn = partial(toolbar.select, 'Policy') lcl_btn = partial(toolbar.select, 'Lifecycle') mon_btn = partial(toolbar.select, 'Monitoring') pwr_btn = partial(toolbar.select, 'Power') create_button = form_buttons.FormButton("Create") manage_policies_tree = CheckboxTree("//div[@id='protect_treebox']/ul") manage_policies_page = Region(locators={ 'save_button': form_buttons.save, }) template_select_form = Form(fields=[('template_table', Table('//div[@id="pre_prov_div"]//table') ), ('cancel_button', form_buttons.cancel)]) snapshot_form = Form( fields=[('name', Input('name')), ('description', Input('description')), ('snapshot_memory', Input('snap_memory')), ( 'create_button', create_button), ('cancel_button', form_buttons.cancel)]) retirement_date_form = Form(
import re from cfme.common.provider import BaseProvider from cfme.fixtures import pytest_selenium as sel from cfme.web_ui import (Region, Form, AngularSelect, form_buttons, Input, Quadicon) from cfme.web_ui.menu import nav from utils.db import cfmedb from utils.varmeth import variable from . import cfg_btn, mon_btn, pol_btn, MiddlewareBase details_page = Region(infoblock_type='detail') nav.add_branch( 'middleware_providers', { 'middleware_provider_new': lambda _: cfg_btn('Add a New Middleware Provider'), 'middleware_provider': [ lambda ctx: sel.check(Quadicon(ctx['provider'].name).checkbox), { 'middleware_provider_edit': lambda _: cfg_btn('Edit Selected Middleware Provider'), 'middleware_provider_edit_tags': lambda _: pol_btn('Edit Tags') } ], 'middleware_provider_detail': [ lambda ctx: sel.click(Quadicon(ctx['provider'].name)), { 'middleware_provider_edit_detail': lambda _: cfg_btn('Edit this Middleware Provider'), 'middleware_provider_timelines_detail': lambda _: mon_btn('Timelines'), 'middleware_provider_edit_tags_detail':
product_assistance = Region(locators={ 'quick_start_guide': { version.LOWEST: "//a[normalize-space(.)='Quick Start Guide']", "5.4.0.1": None }, 'insight_guide': { version.LOWEST: "//a[normalize-space(.)='Insight Guide']", '5.5': "//a[normalize-space(.)='Infrastructure Inventory Guide']" }, 'control_guide': { version.LOWEST: "//a[normalize-space(.)='Control Guide']", '5.5': "//a[normalize-space(.)='Defining Policies Profiles Guide']" }, 'lifecycle_and_automation_guide': { version.LOWEST: "//a[normalize-space(.)='Lifecycle and Automation Guide']", '5.5': "//a[normalize-space(.)='Methods For Automation Guide']" }, 'integrate_guide': { '5.4': "//a[normalize-space(.)='REST API Guide']", '5.5': None }, 'user_guide': { version.LOWEST: None, "5.4.0.1": "//a[normalize-space(.)='User Guide']", '5.5': "//a[normalize-space(.)='General Configuration Guide']" }, 'monitoring_guide': { version.LOWEST: None, '5.5': "//a[normalize-space(.)='Monitoring Alerts Reporting Guide']" }, 'providers_guide': { version.LOWEST: None, '5.5': "//a[normalize-space(.)='Providers Guide']" }, 'scripting_actions_guide': { version.LOWEST: None, '5.5': "//a[normalize-space(.)='Scripting Actions Guide']" }, 'vm_hosts_guide': { version.LOWEST: None, '5.5': "//a[normalize-space(.)='Virtual Machines Hosts Guide']" }, 'settings_and_operations_guide': { version.LOWEST: "//a[normalize-space(.)='Settings and Operations Guide']", '5.5': None }, 'red_hat_customer_portal': "//a[normalize-space(.)='Red Hat Customer Portal']" }, title='About', identifying_loc='quick_start_guide', infoblock_type="form")
from cfme.web_ui.menu import nav from utils import deferred_verpick, version from utils.timeutil import parsetime from utils.pretty import Pretty from utils.wait import wait_for page = Region( title="Dashboard", locators={ 'reset_widgets_button': { version.LOWEST: toolbar.root_loc('Reset Dashboard Widgets'), '5.5.0.11': toolbar.root_loc('Reset Dashboard Widgets to the defaults'), }, 'csrf_token': "//meta[@name='csrf-token']", 'user_dropdown': { version.LOWEST: '//div[@id="page_header_div"]//li[contains(@class, "dropdown")]', '5.4': '//nav//ul[contains(@class, "navbar-utility")]' '/li[contains(@class, "dropdown")]/a', '5.6.0.1': '//nav//a[@id="dropdownMenu2"]', } }, identifying_loc='reset_widgets_button') def click_top_right(item): base_locator = '//nav//a[@id="dropdownMenu2"]/../ul//a[normalize-space(.)="{}"]' sel.click(page.user_dropdown) sel.click(base_locator.format(item), wait_ajax=False)
Usage: tb = web_ui.toolbar tb.select('Configuration', 'Add a New Host') """ import cfme.fixtures.pytest_selenium as sel from selenium.webdriver.common.by import By from cfme.exceptions import ToolbarOptionGreyed from cfme.web_ui import Region from xml.sax.saxutils import quoteattr # Common locators locators = Region( locators={ 'grid_view': "//div[@title='Grid View']", 'list_view': "//div[@title='List View']", 'tile_view': "//div[@title='Tile View']" }) def root_loc(root): """ Returns the locator of the root button Args: root: The string name of the button. Returns: A locator for the root button. """ return ( By.XPATH, "//div[contains(@class, 'dhx_toolbar_btn')][contains(@title, %s)]" % quoteattr(root))