cfme.web_ui package

Module contents

Provides a number of objects to help with managing certain elements in the CFME UI.

Specifically there are two categories of objects, organizational and elemental.
class cfme.web_ui.AngularCalendarInput(input_name, click_away_element)[source]

Bases: utils.pretty.Pretty

clear()[source]
clear_button[source]
fill(value)[source]
input[source]
locate()[source]
pretty_attrs = ('input_name', 'click_away_element')
class cfme.web_ui.AngularSelect(loc, none=None, multi=False)[source]

Bases: object

BUTTON = "//button[@data-id='{}']"
all_options[source]
classes[source]

Combines class from the button and from select.

did[source]
first_selected_option[source]
first_selected_option_text[source]
is_open[source]
locate()[source]
open()[source]
options[source]
select[source]
select_by_value(value)[source]
select_by_visible_text(text)[source]
class cfme.web_ui.ButtonGroup(key)[source]

Bases: object

active[source]

Returns the alt tag text of the active button in thr group.

choose(alt)[source]

Sets the ButtonGroup to select the button identified by the alt text.

locate()[source]

Moves to the element

locator[source]
locator_base[source]
status(alt)[source]

Returns the status of the button identified by the Alt Text of the image.

class cfme.web_ui.Calendar(name)[source]

Bases: utils.pretty.Pretty

A CFME calendar form field

Calendar fields are readonly, and managed by the dxhtmlCalendar widget. A Calendar field will accept any object that can be coerced into a string, but the value may not match the format expected by dhtmlxCalendar or CFME. For best results, either a datetime.date or datetime.datetime object should be used to create a valid date field.

Parameters:name – “name” property of the readonly calendar field.

Usage:

calendar = web_ui.Calendar("miq_date_1")
web_ui.fill(calendar, date(2000, 1, 1))
web_ui.fill(calendar, '1/1/2001')
locate()[source]
class cfme.web_ui.CheckboxSelect(search_root, text_access_func=None)[source]

Bases: utils.pretty.Pretty

Class used for filling those bunches of checkboxes I (@mfalesni) always hated to search for.

Can fill by values, text or both. To search the text for the checkbox, you have 2 choices:

  • If the text can be got from parent’s tag (like <div><input type=”checkbox”>blablabla</div>

    where blablabla is the checkbox’s description looked up), you can leave the text_access_func unfilled.

  • If there is more complicated layout and you don’t mind a bit slower operation, you can pass

    the text_access_func, which should be like lambda checkbox_el: get_text_of(checkbox_el). The checkbox WebElement is passed to it and the description text is the expected output of the function.

Parameters:
  • search_root – Root element for checkbox search
  • text_access_func – Function returning descriptive text about passed CB element.
check(values)[source]

Checking function.

Parameters:values – Dictionary with key=CB name, value=bool with status.

Look in the function to see.

checkbox_by_id(id)[source]

Find checkbox’s WebElement by id.

checkbox_by_text(text)[source]

Returns checkbox’s WebElement by searched by its text.

checkboxes[source]

All checkboxes.

pretty_attrs = ['_root']
select_all()[source]

Selects all checkboxes.

selected_checkboxes[source]

Only selected checkboxes.

selected_values[source]

Only selected checkboxes’ values.

unselect_all()[source]

Unselects all checkboxes.

unselected_checkboxes[source]

Only unselected checkboxes.

unselected_values[source]

Only unselected checkboxes’ values.

class cfme.web_ui.CheckboxTable(table_locator, header_offset=0, body_offset=0, header_checkbox_locator=None, body_checkbox_locator=None)[source]

Bases: cfme.web_ui.Table

Table with support for checkboxes

Parameters:
  • table_locator – See cfme.web_ui.Table
  • header_checkbox_locator – Locator of header checkbox (default None) Specify in case the header checkbox is not part of the header row
  • body_checkbox_locator – Locator for checkboxes in body rows
  • header_offset – See cfme.web_ui.Table
  • body_offset – See cfme.web_ui.Table
deselect_all()[source]

Deselect all rows using the header checkbox or one by one if not present

deselect_row(header, value)[source]

Deselect a single row specified by column header and cell value

Parameters:

Returns: True if successful, False otherwise

deselect_row_by_cells(cells)[source]

Deselect the first row matched by cells

Parameters:cells – See Table.find_rows_by_cells()
deselect_rows(cell_map)[source]

Deselect multiple rows

Parameters:cell_map – See Table.click_cells()
Raises:NotAllCheckboxesFound – If some cells were unable to be found
deselect_rows_by_cells(cells)[source]

Deselect the rows matched by cells

Parameters:cells – See Table.find_rows_by_cells()
deselect_rows_by_indexes(*indexes)[source]

Deselect rows specified by row indexes (starting with 0)

header_checkbox[source]

Checkbox used to select/deselect all rows

select_all()[source]

Select all rows using the header checkbox or one by one if not present

select_row(header, value)[source]

Select a single row specified by column header and cell value

Parameters:

Returns: True if successful, False otherwise

select_row_by_cells(cells)[source]

Select the first row matched by cells

Parameters:cells – See Table.find_rows_by_cells()
select_rows(cell_map)[source]

Select multiple rows

Parameters:cell_map – See Table.click_cells()
Raises:NotAllCheckboxesFound – If some cells were unable to be found
select_rows_by_cells(cells)[source]

Select the rows matched by cells

Parameters:cells – See Table.find_rows_by_cells()
select_rows_by_indexes(*indexes)[source]

Select rows specified by row indexes (starting with 0)

class cfme.web_ui.CheckboxTree(locator)[source]

Bases: cfme.web_ui.Tree

Tree that has a checkbox on each node, adds methods to check/uncheck them

check_node(*path)[source]

Convenience function to check a node

Parameters:*path – The path as multiple positional string arguments denoting the course to take.
uncheck_node(*path)[source]

Convenience function to uncheck a node

Parameters:*path – The path as multiple positional string arguments denoting the course to take.
class cfme.web_ui.ColorGroup(key)[source]

Bases: object

active[source]

Returns the alt tag text of the active button in thr group.

choose(color)[source]

Sets the ColorGroup to select the button identified by the title text.

locate()[source]

Moves to the element

status(color)[source]

Returns the status of the color button identified by the Title Text of the image.

class cfme.web_ui.DHTMLSelect(loc, multi=False, none=None)[source]

Bases: cfme.fixtures.pytest_selenium.Select

A special Select object for CFME’s icon enhanced DHTMLx Select elements.

Parameters:loc – A locator.

Returns a cfme.web_ui.DHTMLSelect object.

all_selected_options[source]

Returns all selected options.

Note: Since the DHTML select can only have one option selected at a time, we
simple return the first element (the only element).

Returns: A Web element.

first_selected_option[source]

Returns the first selected option in the DHTML select

Note: In a DHTML select, there is only one option selectable at a time.

Returns: A webelement.

locate()[source]
options[source]

Returns a list of options of the select as webelements.

Returns: A list of Webelements.

select_by_index(index, _cascade=None)[source]

Selects an option by index.

Parameters:index – The select element’s option by index.
select_by_value(value, _cascade=None)[source]

Selects an option by value.

Parameters:value – The select element’s option value.
select_by_visible_text(text)[source]

Selects an option by visible text.

Parameters:text – The select element option’s visible text.
class cfme.web_ui.DriftGrid(loc="//div[@id='drift_grid_div']")[source]

Bases: utils.pretty.Pretty

Class representing the table (grid) specific to host drift analysis comparison page

cell_indicates_change(row_text, col_index)[source]

Finds out if a cell, specified by column index and row text, indicates change

Parameters:
  • row_text – Title text of the cell’s row
  • col_index – Column index of the cell

Note

col_index of 0 is used for the 2nd actual column in the drift grid, because the 1st column does not contain headers, only row descriptions.

Returns:True if there is a change present, False otherwise
expand_all_sections()[source]

Expands all sections to make the row elements found therein available

get_cell(row_text, col_index)[source]

Finds cell element of the grid specified by column index and row text

Parameters:
  • row_text – Title text of the cell’s row
  • col_index – Column index of the cell, starting with 0 for 1st data-containing column

Note

col_index of 0 is used for the 2nd actual column in the drift grid, because the 1st column does not contain headers, only row descriptions.

Returns:Selenium element of the cell.
class cfme.web_ui.DynamicTable(root_loc, default_row_item=None)[source]

Bases: utils.pretty.Pretty

A table that can add or remove the rows.

ROWS = ".//tbody/tr[not(contains(@id, 'new_tr'))]"
class Row(table, root)[source]

Bases: object

inputs[source]
inputs_for_filling[source]
values[source]
DynamicTable.add_row(data)[source]
DynamicTable.clear()[source]
DynamicTable.click_add()[source]
DynamicTable.click_save()[source]
DynamicTable.delete_row(by)[source]
DynamicTable.header_names[source]
DynamicTable.pretty_attrs = ('root_loc', 'default_row_item')
DynamicTable.rows[source]
class cfme.web_ui.EmailSelectForm[source]

Bases: utils.pretty.Pretty

Class encapsulating the e-mail selector, eg. in Control/Alarms editing.

fields = <cfme.web_ui.Region title=None>
remove_email(email)[source]

Remove specified e-mail

Parameters:email – E-mail to remove
to_emails[source]

Returns list of e-mails that are selected

user_emails[source]

Returns list of e-mail that users inside CFME have so that they can be selected

class cfme.web_ui.Filter(fields=None, identifying_loc=None)[source]

Bases: cfme.web_ui.Form

Filters requests pages

This class inherits Form as its base and adds a few methods to assist in filtering request pages.

Usage:

f = Filter(fields=[
    ('type', Select('//select[@id="type_choice"]')),
    ('approved', Input("state_choice__approved")),
    ('denied', Input"state_choice__denied")),
    ('pending_approval', Input("state_choice__pending_approval")),
    ('date', Select('//select[@id="time_period"]')),
    ('reason', Input("reason_text")),
])

f.apply_filter(type="VM Clone", approved=False,
    pending_approval=False, date="Last 24 Hours", reason="Just Because")
apply_filter(**kwargs)[source]

Method to apply a filter.

First resets the filter to default and then applies the filter.

Parameters:**kwargs – A dictionary of form elements to fill and their values.
buttons = {'reset': '//div[@id="buttons_on"]//a[@title="Reset filter changes"]', 'apply': '//div[@id="buttons_on"]//a[@title="Apply the selected filters"]', 'default_off': '//div[@id="buttons_off"]/li/a/img[@alt="Set filters to default"]', 'default_on': '//div[@id="buttons_on"]/li/a/img[@alt="Set filters to default"]'}
default_filter()[source]

Method to reset the filter back to defaults.

reset_filter()[source]

Method to reset the changes to the filter since last applying.

class cfme.web_ui.Form(fields=None, identifying_loc=None)[source]

Bases: cfme.web_ui.Region

A class for interacting with Form elements on pages.

The Form class takes a set of locators and binds them together to create a unified Form object. This Form object has a defined field order so that the user does not have to worry about which order the information is provided. This enables the data to be provided as a dict meaning it can be passed directly from yamls. It inherits the base Region class, meaning that locators can still be referenced in the same way a Region’s locators can. You can also add one more field which will be a dict of metadata, determining mostly field validity. See field_valid()

Parameters:
  • fields – A list of field name/locator tuples. The argument not only defines the order of the elements but also which elements comprise part of the form.
  • identifying_loc – A locator which should be present if the form is visible.

Usage:

provider_form = web_ui.Form(
    fields=[
        ('type_select', "//*[@id='server_emstype']"),
        ('name_text', "//*[@id='name']"),
        ('hostname_text', "//*[@id='hostname']"),
        ('ipaddress_text', "//*[@id='ipaddress']"),
        ('amazon_region_select', "//*[@id='hostname']"),
        ('api_port', "//*[@id='port']"),
    ])

Forms can then be filled in like so.:

provider_info = {
   'type_select': "OpenStack",
   'name_text': "RHOS-01",
   'hostname_text': "RHOS-01",
   'ipaddress_text': "10.0.0.0",
   'api_port': "5000",
}
web_ui.fill(provider_form, provider_info)

Note

Using supertuples in a list, although ordered due to the properties of a List, will not overide the field order defined in the Form.

field_valid(field_name)[source]

Add the validity constraints here.

fill(fill_data)[source]
pretty_attrs = ['fields']
class cfme.web_ui.InfoBlock(title)[source]

Bases: utils.pretty.Pretty

DETAIL = 'detail'
FORM = 'form'
class Member(ib, name)[source]

Bases: utils.pretty.Pretty

container[source]
element[source]
elements[source]
icon_href[source]
locate()[source]
pair[source]
pair_locator[source]
pretty_attrs = ('name', 'ib')
text[source]
title[source]
InfoBlock.by_member_icon(icon)[source]

In case you want to find the item by icon in the value field (like OS infra diff.)

classmethod InfoBlock.container(args, **kwargs)[source]
classmethod InfoBlock.element(*args, **kwargs)[source]
classmethod InfoBlock.elements(*args, **kwargs)[source]
classmethod InfoBlock.icon_href(*args, **kwargs)[source]
InfoBlock.member(name)[source]
InfoBlock.pretty_attrs = ['title']
InfoBlock.root[source]
classmethod InfoBlock.text(*args, **kwargs)[source]
InfoBlock.type[source]
class cfme.web_ui.Input(*names, **kwargs)[source]

Bases: utils.pretty.Pretty

Class designed to handle things about <input> tags that have name attr in one place.

Also applies on textarea, which is basically input with multiple lines (if it has name).

Parameters:*names – Possible values (or) of the name attribute.
Keywords:
use_id: Whether to use id instead of name. Useful if there is some input that does
not have name attribute present.
angular_help_block[source]

Returns the angular helper text (like ‘Required’).

locate()[source]
names[source]
pretty_attrs = ['_names', '_use_id']
class cfme.web_ui.MultiFill(*fields)[source]

Bases: object

Class designed to fill the same value to multiple fields

Parameters:*fields – The fields where the value will be mirrored
class cfme.web_ui.MultiSelect(available_select=None, selected_select=None, select_arrow=None, deselect_arrow=None)[source]

Bases: cfme.web_ui.Region

Represents a UI widget where there are two select boxes, one with possible selections, and another with selected items. Has two arrow buttons to move items between the two

class cfme.web_ui.Quadicon(name, qtype=None)[source]

Bases: utils.pretty.Pretty

Represents a single quadruple icon in the CFME UI.

A Quadicon contains multiple quadrants. These are accessed via attributes. The qtype is currently one of the following and determines which attribute names are present. They are mapped internally and can be reassigned easily if the UI changes.

A Quadicon is used by defining the name of the icon and the type. After that, it can be used to obtain the locator of the Quadicon, or query its quadrants, via attributes.

Parameters:
  • name – The label of the icon.
  • qtype – The type of the quad icon. By default it is None, therefore plain quad without any retrievable data usable for selecting/clicking.

Usage:

qi = web_ui.Quadicon('hostname.local', 'host')
qi.creds
click(qi)

Known Quadicon Types and Attributes

  • host - from the infra/host page - has quads:
      1. no_vm - Number of VMs
      1. state - The current state of the host
      1. vendor - The vendor of the host
      1. creds - If the creds are valid
  • infra_prov - from the infra/providers page - has quads:
      1. no_host - Number of hosts
      1. Blank
      1. vendor - The vendor of the provider
      1. creds - If the creds are valid
  • vm - from the infra/virtual_machines page - has quads:
      1. os - The OS of the vm
      1. state - The current state of the vm
      1. vendor - The vendor of the vm’s host
      1. no_snapshot - The number of snapshots
      1. policy - The state of the policy
  • cloud_prov - from the cloud/providers page - has quads:
      1. no_instance - Number of instances
      1. no_image - Number of machine images
      1. vendor - The vendor of the provider
      1. creds - If the creds are valid
  • instance - from the cloud/instances page - has quads:
      1. os - The OS of the instance
      1. state - The current state of the instance
      1. vendor - The vendor of the instance’s host
      1. no_snapshot - The number of snapshots
      1. policy - The state of the policy
  • datastore - from the infra/datastores page - has quads:
      1. type - File system type
      1. no_vm - Number of VMs
      1. no_host - Number of hosts
      1. avail_space - Available space
  • repository - from the infra/repositories page - has no quads
  • cluster - from the infra/cluster page - has no quads
  • resource_pool - from the infra/resource_pool page - has no quads
  • stack - from the clouds/stacks page - has no quads

Returns: A Quadicon object.

QUADS = {'resource_pool': {}, 'template': {'vendor': ('c', 'img'), 'state': ('b', 'img'), 'os': ('a', 'img'), 'no_snapshot': ('d', 'txt')}, 'repository': {}, None: {}, 'image': {'vendor': ('c', 'img'), 'state': ('b', 'img'), 'os': ('a', 'img'), 'no_snapshot': ('d', 'txt')}, 'vm': {'policy': ('g', 'img'), 'vendor': ('c', 'img'), 'state': ('b', 'img'), 'os': ('a', 'img'), 'no_snapshot': ('d', 'txt')}, 'cluster': {}, 'host': {'no_vm': ('a', 'txt'), 'vendor': ('c', 'img'), 'state': ('b', 'img'), 'creds': ('d', 'img')}, 'datastore': {'no_host': ('c', 'txt'), 'no_vm': ('b', 'txt'), 'type': ('a', 'img'), 'avail_space': ('d', 'img')}, 'stack': {}, 'cloud_prov': {'no_vm': ('a', 'txt'), 'vendor': ('b', 'img'), 'creds': ('d', 'img'), 'no_image': ('b', 'txt')}, 'instance': {'policy': ('g', 'img'), 'vendor': ('c', 'img'), 'state': ('b', 'img'), 'os': ('a', 'img'), 'no_snapshot': ('d', 'txt')}, 'infra_prov': {'no_host': ('a', 'txt'), 'vendor': ('c', 'img'), 'creds': ('d', 'img')}}
classmethod all(qtype=None, this_page=False)[source]

Allows iteration over Quadicons.

Parameters:
  • qtype – Quadicon type. Refer to the constructor for reference.
  • this_page – Whether to look for Quadicons only on current page (do not list pages).

Returns: list of Quadicon

any_present = False[source]
check_for_single_quadrant_icon[source]

Checks if the quad icon is a single quadrant icon.

checkbox()[source]

Returns: a locator for the internal checkbox for the quadicon

exists[source]
classmethod first(qtype=None)[source]
static get_first_quad_title()[source]
locate()[source]

Returns: a locator for the quadicon anchor

name[source]

Returns name of the quadicon.

pretty_attrs = ['_name', '_qtype']
qtype[source]
static select_first_quad()[source]
class cfme.web_ui.Radio(*names, **kwargs)[source]

Bases: cfme.web_ui.Input

A class for Radio button groups

Radio allows the usage of HTML radio elements without resorting to previous practice of iterating over elements to find the value. The name of the radio group is passed and then when choices are required, the locator is built.

Parameters:name – The HTML elements name attribute that identifies a group of radio buttons.

Usage:

radio = Radio("schedule__schedule_type")

A specific radio element can then be returned by running the following:

el = radio.choice('immediately')
click(el)

The Radio object can be reused over and over with repeated calls to the Radio.choice() method.

choice(val)[source]

Returns the locator for a choice

Parameters:val – A string representing the value attribute of the specific radio element.

Returns: A string containing the XPATH of the specific radio element.

observer_wait(val)[source]
class cfme.web_ui.Region(locators=None, title=None, identifying_loc=None, **kwargs)[source]

Bases: utils.pretty.Pretty

Base class for all UI regions/pages

Parameters:
  • locators – A dict of locator objects for the given region
  • title – A string containing the title of the page, or a versioned dict of page title strings
  • identifying_loc – Single locator key from locators used by Region.is_displayed() to check if the region is currently visible

Usage:

page = Region(locators={
    'configuration_button': (By.CSS_SELECTOR, "div.dhx_toolbar_btn[title='Configuration']"),
    'discover_button': (By.CSS_SELECTOR,
        "tr[title='Discover Cloud Providers']>td.td_btn_txt>" "div.btn_sel_text")
    },
    title='Cloud Providers',
    identifying_loc='discover_button'
)

The elements can then accessed like so:

page.configuration_button

Locator attributes will return the locator tuple for that particular element, and can be passed on to other functions, such as element() and click().

Note

When specifying a region title, omit the “Cloudforms Management Engine: ” or “ManageIQ: ” prefix. They’re included on every page, and different for the two versions of the appliance, and is_displayed() strips them off before checking for equality.

is_displayed()[source]

Checks to see if the region is currently displayed.

Returns: A boolean describing if the region is currently displayed

pretty_attrs = ['title']
title[source]
class cfme.web_ui.ScriptBox(name=None, ta_locator="//textarea[contains(@id, 'method_data')]")[source]

Bases: utils.pretty.Pretty

Represents a script box as is present on the customization templates pages. This box has to be activated before keys can be sent. Since this can’t be done until the box element is visible, and some dropdowns change the element, it must be activated “inline”.

Args:

get_value()[source]
name[source]
pretty_attrs = ['locator']
class cfme.web_ui.ShowingInputs(*locators, **kwargs)[source]

Bases: utils.pretty.Pretty

This class abstracts out as a container of inputs, that appear after preceeding was filled.

Parameters:*locators – In-order-of-display specification of locators.
Keywords:
min_values: How many values are required (Default: 0)
pretty_attrs = ['locators', 'min_values']
zip(with_values)[source]
class cfme.web_ui.SortTable(table_locator, header_offset=0, body_offset=0)[source]

Bases: cfme.web_ui.Table

This table is the same as Table, but with added sorting functionality.

click_header_cell(text)[source]

Clicks on the header to change sorting conditions.

Parameters:text – Header cell text.
sort_by(header, order)[source]

Sorts the table by given conditions

Parameters:
  • header – Text of the header cell to use for sorting.
  • order – ascending or descending
sort_order[source]

Return order.

Returns: ‘ascending’ or ‘descending’

sorted_by[source]

Return column name what is used for sorting now.

class cfme.web_ui.SplitCheckboxTable(header_data, body_data, header_checkbox_locator=None, body_checkbox_locator=None)[source]

Bases: cfme.web_ui.SplitTable, cfme.web_ui.CheckboxTable

SplitTable with support for checkboxes

Parameters:
class cfme.web_ui.SplitTable(header_data, body_data)[source]

Bases: cfme.web_ui.Table

Table that supports the header and body rows being in separate tables

Parameters:
  • header_data – A tuple, containing an element locator and an offset value. These point to the container of the header row. The offset is used in case there is a padding row above the header, or in the case that the header and the body are contained inside the same table element.
  • body_data – A tuple, containing an element locator and an offset value. These point to the container of the body rows. The offset is used in case there is a padding row above the body rows, or in the case that the header and the body are contained inside the same table element.

Usage:

table = SplitTable(header_data=('//div[@id="header_table"]//table/tbody', 0),
    body_data=('//div[@id="body_table"]//table/tbody', 1))

The HTML code for a split table looks something like this:

<div id="prov_pxe_img_div">
  <table id="header_table">
      <tbody>
          <tr>
              <td>Name</td>
              <td>Animal</td>
              <td>Size</td>
          </tr>
      </tbody>
  </table>
  <table id="body_table">
      <tbody>
          <tr>
              <td>Useless</td>
              <td>Padding</td>
              <td>Row</td>
          </tr>
          <tr>
              <td>John</td>
              <td>Monkey</td>
              <td>Small</td>
          </tr>
          <tr>
              <td>Mike</td>
              <td>Tiger</td>
              <td>Large</td>
          </tr>
      </tbody>
  </table>
</div>

Note the use of the offset to skip the “Useless Padding Row” in body_data. Most split tables require an offset for both the heading and body rows.

body[source]

Property representing the element that contains body rows

header_row[source]

Property representing the <tr> element that contains header cells

locate()[source]
class cfme.web_ui.Table(table_locator, header_offset=0, body_offset=0)[source]

Bases: utils.pretty.Pretty

Helper class for Table/List objects

Turns CFME custom Table/Lists into iterable objects using a generator.

Parameters:
  • table_locator – locator pointing to a table element with child thead and tbody elements representing that table’s header and body row containers
  • header_offset – In the case of a padding table row above the header, the row offset can be used to skip rows in <thead> to locate the correct header row. This offset is 1-indexed, not 0-indexed, so an offset of 1 is the first child row element
  • body_offset – In the case of a padding table row above the body rows, the row offset can be used to skip rows in <ttbody> to locate the correct header row. This offset is 1-indexed, not 0-indexed, so an offset of 1 is the first child row element
header_indexes[source]

A dict of header names related to their int index as a column.

Usage:

table = Table('//div[@id="prov_pxe_img_div"]//table')

The HTML code for the table looks something like this:

<div id="prov_pxe_img_div">
  <table>
      <thead>
          <tr>
              <th>Name</th>
              <th>Animal</th>
              <th>Size</th>
          </tr>
      </thead>
      <tbody>
          <tr>
              <td>John</td>
              <td>Monkey</td>
              <td>Small</td>
          </tr>
          <tr>
              <td>Mike</td>
              <td>Tiger</td>
              <td>Large</td>
          </tr>
      </tbody>
  </table>
</div>

We can now click on an element in the list like so, by providing the column name and the value that we are searching for:

table.click_cell('name', 'Mike')

We can also perform the same, by using the index of the column, like so:

table.click_cell(1, 'Tiger')

Additionally, the rows of a table can be iterated over, and that row’s columns can be accessed by name or index (left to right, 0-index):

for row in table.rows()
    # Get the first cell in the row
    row[0]
    # Get the row's contents for the column with header 'Row Name'
    # All of these will work, though the first is preferred
    row.row_name, row['row_name'], row['Row Name']

When doing bulk opererations, such as selecting rows in a table based on their content, the *_by_cells methods are able to find matching row much more quickly than iterating, as the work can be done with fewer selenium calls.

Note

A table is defined by the containers of the header and data areas, and offsets to them. This allows a table to include one or more padding rows above the header row. In the example above, there is no padding row, as our offset values are set to 0.

class Row(row_element, parent_table)[source]

Bases: utils.pretty.Pretty

An object representing a row in a Table.

The Row object returns a dymanically addressable attribute space so that the tables headers are automatically generated.

Parameters:
  • row_element – A table row WebElement
  • parent_tableTable containing row_element

Notes

Attributes are dynamically generated. The index/key accessor is more flexible than the attr accessor, as it can operate on int indices and header names.

columns[source]

A list of WebElements corresponding to the <td> elements in this row

locate()[source]
pretty_attrs = ['row_element', 'table']
Table.body[source]

Property representing the <tbody> element that contains body rows

Table.click_cell(header, value)[source]

Clicks on a cell defined in the row.

Uses the header identifier and a value to determine which cell to click on.

Parameters:
  • header – A string or int, describing which column to inspect.
  • value – The value to be compared when trying to identify the correct cell to click the cell in.

Returns: True if item was found and clicked, else False.

Table.click_cells(cell_map)[source]

Submits multiple cells to be clicked on

Parameters:cell_map

A mapping of header names and values, representing cells to click. As an example, {'name': ['wing', 'nut']}, {'age': ['12']} would click on the cells which had wing and nut in the name column and 12 in the age column. The yaml example for this would be as follows:

list_items:
    name:
        - wing
        - nut
    age:
        - 12
Raises:NotAllItemsClicked – If some cells were unable to be found.
Table.click_row_by_cells(cells, click_column=None, partial_check=False)[source]

Click the cell at click_column in the first row matched by cells

Parameters:
Table.click_rows_by_cells(cells, click_column=None, partial_check=False)[source]

Click the cell at click_column in the rows matched by cells

Parameters:
  • cells – See Table.find_rows_by_cells()
  • click_column – Which column in the row to click, defaults to None, which will attempt to click the row element

Note

The value of click_column can be a string or an int, and will be passed directly to the item accessor (__getitem__) for Table.Row

Table.create_row_from_element(row_element)[source]

Given a row element in this table, create a Table.Row

Parameters:row_element – A table row (<tr>) WebElement representing a row in this table.

Returns: A Table.Row for row_element

Table.find_cell(header, value)[source]

Finds an item in the Table by iterating through each visible item, this work used to be done by the :py:meth::click_cell method but has not been abstracted out to be called separately.

Parameters:
  • header – A string or int, describing which column to inspect.
  • value – The value to be compared when trying to identify the correct cell to click.

Returns: WebElement of the element if item was found, else None.

Table.find_row(header, value)[source]

Finds a row in the Table by iterating through each visible item.

Parameters:
  • header – A string or int, describing which column to inspect.
  • value – The value to be compared when trying to identify the correct row to return.
Returns:

Table.Row containing the requested cell, else None.

Table.find_row_by_cells(cells, partial_check=False)[source]

Find the first row containing cells

Parameters:cells – See Table.find_rows_by_cells()

Returns: The first matching row found, or None if no matching row was found

Table.find_rows_by_cells(cells, partial_check=False)[source]

A fast row finder, based on cell content.

Parameters:cells – A dict of header: value pairs or a sequence of nested (header, value) pairs.
Returns: A list of containing Table.Row objects whose contents
match all of the header: value pairs in cells
Table.header_indexes[source]

Dictionary of header name – column index for this table’s rows

Derived from headers

Table.header_row[source]

Property representing the <tr> element that contains header cells

Table.headers[source]

List of <td> or <th> elements in header_row

Table.locate()[source]
Table.pretty_attrs = ['_loc']
Table.rows()[source]

A generator method holding the Row objects

This generator yields Row objects starting at the first data row.

Yields:Table.Row object corresponding to the next row in the table.
class cfme.web_ui.Timelines(loc)[source]

Bases: utils.pretty.Pretty

A Timelines object represents the Timelines widget in CFME

Parameters:loc – A locator for the Timelines element, usually the div with id miq_timeline.
class Event(element)[source]

Bases: cfme.web_ui.Object

An event object.

block_info()[source]

Attempts to return a dict with the information from the popup.

close_block()[source]

Closes the events info block.

close_button = '//div[@class="timeline-event-bubble-title"]/../../div[contains(@style, \'close-button\')]'
data_block = '//div[@class="timeline-event-bubble-title"]/../..//div[@class="timeline-event-bubble-body"]'
image[source]

Returns the image name of an event.

open_block()[source]

Opens the events info block.

window_loc = '//div[@class="timeline-event-bubble-title"]/../..'
class Timelines.Marker(element)[source]

Bases: cfme.web_ui.Object

A proxied object in case it needs more methods further down the line.

class Timelines.Object(element)[source]

Bases: utils.pretty.Pretty

A generic timelines object.

Parameters:element – A WebElement for the event.
locate()[source]
pretty_attrs = ['element']
Timelines.events()[source]

A generator yielding all events.

Timelines.find_first_event_in_range()[source]

Finds the first event on screen.

Timelines.find_first_marker_in_range()[source]

Finds the first marker on screen.

Timelines.find_visible_events_for_vm(vm_name)[source]

Finds all events for a given vm.

Parameters:vm_name – The vm name.
Timelines.markers()[source]

A generator yielding all markers.

Timelines.pretty_attrs = ['element']
Timelines.visible_events()[source]

A generator giving all visible events.

class cfme.web_ui.Tree(locator)[source]

Bases: utils.pretty.Pretty

A class directed at CFME Tree elements

The Tree class aims to deal with all kinds of CFME trees, at time of writing there are two distinct types. One which uses <table> elements and another which uses <ul> elements.

Parameters:locator – This is a locator object pointing to either the outer <table> or <ul> element which contains the rest of the table.

Returns: A Tree object.

A Tree object is set up by using a locator which contains the node elements. This element will usually be a <ul> in the case of a Dynatree, or a <table> in the case of a Legacy tree.

Usage:

tree = web_ui.Tree((By.XPATH, '//table//tr[@title="Datastore"]/../..'))

The path can then be navigated to return the last object in the path list, like so:

tree.click_path('Automation', 'VM Lifecycle Management (VMLifecycle)',
    'VM Migrate (Migrate)')

Each path element will be expanded along the way, but will not be clicked.

When used in a Form, a list of path tuples is expected in the form fill data. The paths will be passed individually to Tree.check_node():

form = Form(fields=[
    ('tree_field', List(locator)),
])

form_fill_data = {
    'tree_field': [
        ('Tree Node', 'Value'),
        ('Tree Node', 'Branch Node', 'Value'),
    ]
]

Note

For legacy trees, the first element is often ignored as it is not a proper tree element ie. in Automate->Explorer the Datastore element doesn’t really exist, so we omit it from the click map.

Legacy trees rely on a complex <table><tbody><tr><td> setup. We class a <tbody> as a node.

Note: Dynatrees, rely on a <ul><li> setup. We class a <li> as a node.

classmethod browse(tree, *path)[source]

Browse through tree via path.

If node not found, raises exception. If the browsing reached leaf(str), returns True if also the step was last, otherwise False. If the result of the path is a subtree, it is returned.

Parameters:
  • tree – List with tree.
  • *path – Path to browse.
click_path(*path)[source]

Exposes a path and then clicks it.

Parameters:*path – The path as multiple positional string arguments denoting the course to take.

Returns: The leaf web element.

expand_path(*path)[source]

Clicks through a series of elements in a path.

Clicks through a tree, by expanding the levels in a single straight path and returns the final element without clicking it.

Parameters:*path – The path as multiple positional string arguments denoting the course to take.

Returns: The element at the leaf of the tree.

Raises:
find_path_to(target)[source]

Method used to look up the exact path to an item we know only by its regexp or partial description.

Expands whole tree during the execution.

Parameters:target – Item searched for. Can be regexp made by re.compile, otherwise it is taken as a string for in matching.

Returns: list with path to that item.

classmethod flatten_level(tree)[source]

Extracts just node names from current tree (top).

It makes:

["asd", "fgh", ("ijk", [...]), ("lmn", [...])]

to

["asd", "fgh", "ijk", "lmn"]

Useful for checking of contents of current tree level

node_element(node_name, parent)[source]
node_root_element(node_name, parent)[source]
nodes_root_elements(parent)[source]
pretty_attrs = ['locator']
read_contents(parent=None, unexpand=False)[source]

Reads complete contents of the tree recursively.

Tree is represented as a list. If the item in the list is string, it is leaf element and it is its name. If the item is a tuple, first element of the tuple is the name and second element is the subtree (list).

Parameters:
  • parent – Starting element, used during recursion
  • unexpand – Whether it should unexpand the expanded levels to original state.

Returns: Tree in format mentioned in description

class cfme.web_ui.UpDownSelect(select_loc, up_loc, down_loc)[source]

Bases: cfme.web_ui.Region

Multiselect with two arrows (up/down) next to it. Eg. in AE/Domain priority selection.

Parameters:
  • select_loc – Locator for the select box (without Select element wrapping)
  • up_loc – Locator of the Move Up arrow.
  • down_loc – Locator with Move Down arrow.
get_items()[source]
move_bottom(item)[source]
move_down(item)[source]
move_top(item)[source]
move_up(item)[source]
cfme.web_ui.fill_callable(f, val)[source]

Fill in a Callable by just calling it with the value, allow for arbitrary actions

cfme.web_ui.fill_cb_select_bool(select, all_state)[source]
cfme.web_ui.fill_cb_select_dictlist(select, dictlist)[source]
cfme.web_ui.fill_cb_select_set(select, names)[source]
cfme.web_ui.fill_cb_select_string(select, cb)[source]
cfme.web_ui.fill_checkbox(cb, val)[source]
cfme.web_ui.fill_click(el, val)[source]

Click only when given a truthy value

cfme.web_ui.fill_email_select_form(form, emails)[source]
cfme.web_ui.fill_file(fd, val)[source]
cfme.web_ui.fill_multiselect(ms, items)[source]
cfme.web_ui.fill_password(pwbox, password)[source]
cfme.web_ui.fill_scriptbox(sb, script)[source]

This function now clears and sets the ScriptBox.

cfme.web_ui.fill_select(slist, val)[source]
cfme.web_ui.fill_select_tag(select, value)[source]
cfme.web_ui.fill_text(textbox, val)[source]
cfme.web_ui.get_context_current_page()[source]

Returns the current page name

Returns: A string containing the current page name

cfme.web_ui.select_dhtml(dhtml, s)[source]
cfme.web_ui.select_multiselect(ms, values)[source]
cfme.web_ui.table_in_object(table_title)[source]

If you want to point to tables inside object view, this is what you want to use.

Works both on down- and upstream.

Parameters:table_title – Text in p element preceeding the table

Returns: XPath locator for the desired table.