widgetastic_patternfly4.menu module¶
-
class
widgetastic_patternfly4.menu.BaseCheckboxMenu¶ Bases:
widgetastic_patternfly4.menu.BaseMenuRepresents a checkbox menu.
-
ITEM_LOCATOR= './/label[normalize-space(.)={}]/preceding-sibling::input'¶
-
fill(items)¶ Fills a Checkbox with all items. Example dictionary: {“foo”: True, “bar”: False, “baz”: True}
Parameters: items – A dictionary containing what items to select (True) or deselect (False)
-
item_deselect(items, close=True)¶ Opens the Checkbox and deselects the desired item.
Parameters: - item – Item to be selected
- close – Close the dropdown when finished
-
item_select(items, close=True)¶ Opens the Checkbox and selects the desired item.
Parameters: - item – Item to be selected
- close – Close the dropdown when finished
-
items¶ Returns a list of all CheckboxSelect items as strings.
-
read()¶ Returns a dictionary containing the selected status as bools.
-
-
class
widgetastic_patternfly4.menu.BaseMenu¶ Bases:
objectRepresents the Patternfly Menu.
Most menu’s exist without a toggle to open them (e.g. all the examples in the link below). That is why there is the class level constant IS_ALWAYS_OPEN which defaults to ‘True’.
However, it is possible to have a menu that will only appear based on a button or toggle. In these cases you should inherit from menu and set IS_ALWAYS_OPEN to ‘False’. BUTTON_LOCATOR will also need to be modified to point to the toggle button. In the DOM, the menu widget is usually placed as a sibling to the toggle button. You can either override ROOT or simply pass a locator when the widget is instantiated to point to the parent of the toggle button.
class PermissionsMenu(Menu): IS_ALWAYS_OPEN = False BUTTON_LOCATOR = ".//button[contains(@class, 'pf-c-menu-toggle')]" ROOT = f"{BUTTON_LOCATOR}/.."
https://www.patternfly.org/v4/documentation/react/components/menu
-
BUTTON_LOCATOR= './button'¶
-
IS_ALWAYS_OPEN= True¶
-
ITEMS_LOCATOR= ".//li[contains(@class, 'pf-c-menu__list-item')]"¶
-
ITEM_LOCATOR= ".//*[contains(@class, 'pf-c-menu__list-item') and normalize-space(.)={}]"¶
-
SELECTED_ITEMS_LOCATOR= ".//button[contains(@class, 'pf-m-selected')]"¶
-
TEXT_LOCATOR= ".//div[contains(@class, 'pf-c-menu') and child::button[normalize-space(.)={}]]"¶
-
close(ignore_nonpresent=False)¶ Close the menu
It it is always open we do nothing
Parameters: ignore_nonpresent – Will ignore exceptions due to disabled or missing dropdown
-
fill(value)¶ Fills a Menu with a value or values.
-
is_enabled¶ Returns True if the menu toggle itself is enabled and therefore interactive.
-
is_open¶ Returns True if the Dropdown is open
Some menus are visible without having to click anything, so if the items are displayed we consider that to be open as well.
-
item_element(item, close=True)¶ Returns a WebElement for given item name.
-
item_select(item)¶ Opens the Menu and selects the desired item.
Parameters: item – Item to be selected Raises: MenuItemDisabled– if item is disabled
-
read()¶ Returns a string of the text of the selected option.
-
selected_items¶ Returns a list of all selected items as strings.
-
-
class
widgetastic_patternfly4.menu.CheckboxMenu(parent, text=None, locator=None, logger=None)¶ Bases:
widgetastic_patternfly4.menu.BaseCheckboxMenu,widgetastic_patternfly4.dropdown.Dropdown-
DEFAULT_LOCATOR= './/div[contains(@class, "pf-c-menu")]'¶
-
-
class
widgetastic_patternfly4.menu.Menu(parent, text=None, locator=None, logger=None)¶ Bases:
widgetastic_patternfly4.menu.BaseMenu,widgetastic_patternfly4.dropdown.Dropdown-
DEFAULT_LOCATOR= './/div[contains(@class, "pf-c-menu")]'¶
-
-
exception
widgetastic_patternfly4.menu.MenuItemDisabled¶ Bases:
widgetastic_patternfly4.dropdown.DropdownItemDisabled
-
exception
widgetastic_patternfly4.menu.MenuItemNotFound¶ Bases:
widgetastic_patternfly4.dropdown.DropdownItemNotFound