widgetastic_patternfly4.dropdown module

class widgetastic_patternfly4.dropdown.BaseDropdown

Bases: object

Represents the Patternfly dropdown.

https://www.patternfly.org/v4/documentation/react/components/dropdown

Parameters:text – Text of the button, can be the inner text or the title attribute.
BUTTON_LOCATOR = ".//button[contains(@class, 'pf-c-dropdown__toggle')]"
ITEMS_LOCATOR = ".//ul[contains(@class, 'pf-c-dropdown__menu')]/li"
ITEM_LOCATOR = ".//*[contains(@class, 'pf-c-dropdown__menu-item') and normalize-space(.)={}]"
button_text

Returns a string of the current dropdown name.

close(ignore_nonpresent=False)

Close the dropdown

Parameters:ignore_nonpresent – Will ignore exceptions due to disabled or missing dropdown
has_item(item)

Returns whether the items exists.

Parameters:item – item name
Returns:Boolean - True if enabled, False if not.
is_enabled

Returns if the dropdown itself is enabled and therefore interactive.

is_open

Returns True if the Dropdown is open

item_element(item, close=True, **kwargs)

Returns a WebElement for given item name.

item_enabled(item, close=True, **kwargs)

Returns whether the given item is enabled.

Parameters:item – Name of the item.
Returns:Boolean - True if enabled, False if not.
item_select(item, handle_alert=None, **kwargs)

Opens the dropdown and selects the desired item.

Parameters:
  • item – Item to be selected
  • handle_alert – How to handle alerts. None - no handling, True - confirm, False - dismiss.
Raises:

DropdownItemDisabled

items

Returns a list of all dropdown items as strings.

open()

Opens a dropdown.

opened()

A context manager to open and then close a Dropdown.

read()
class widgetastic_patternfly4.dropdown.BaseGroupDropdown

Bases: object

Dropdown with grouped items in it.

GROUPS_LOCATOR = ".//section[@class='pf-c-dropdown__group']/h1"
GROUP_LOCATOR = ".//section[@class='pf-c-dropdown__group'][h1[normalize-space(.)={}]]"
ITEMS_LOCATOR = ".//section[@class='pf-c-dropdown__group']/ul/li"
groups

Returns a list of all group names as strings.

item_element(item, group_name=None, close=True)

Returns a WebElement for given item name.

item_select(item, group_name=None, handle_alert=None)

Opens the dropdown and selects the desired item. Implemented only for proper kwargs suggestions.

Parameters:
  • item – Item to be selected
  • group_name – name of a group to search in. If not provided - all groups will be checked.
  • handle_alert – How to handle alerts. None - no handling, True - confirm, False - dismiss.
Raises:

DropdownItemDisabled

class widgetastic_patternfly4.dropdown.BaseSplitButtonDropdown

Bases: object

Represents the Patternfly Split Button Dropdown.

https://www.patternfly.org/v4/documentation/react/components/dropdown#split-button-with-text

check()

Check toggle checkbox.

read()
selected

Returns selected or not

toggle_check

This class handles instantiating and caching of the widgets on view.

It stores the class and the parameters it should be instantiated with. Once it is accessed from the instance of the class where it was defined on, it passes the instance to the widget class followed by args and then kwargs.

It also acts as a counter, so you can then order the widgets by their “creation” stamp.

uncheck()

Uncheck toggle checkbox.

class widgetastic_patternfly4.dropdown.Dropdown(parent, text=None, locator=None, logger=None)

Bases: widgetastic_patternfly4.dropdown.BaseDropdown, widgetastic.widget.base.Widget

DEFAULT_LOCATOR = './/div[contains(@class, "pf-c-dropdown")][1]'
ROOT

ParametrizedString modified to return instances of smartloc.Locator

TEXT_LOCATOR = ".//div[contains(@class, 'pf-c-dropdown') and child::button[normalize-space(.)={}]]"
exception widgetastic_patternfly4.dropdown.DropdownDisabled

Bases: Exception

exception widgetastic_patternfly4.dropdown.DropdownItemDisabled

Bases: Exception

exception widgetastic_patternfly4.dropdown.DropdownItemNotFound

Bases: Exception

class widgetastic_patternfly4.dropdown.GroupDropdown(parent, text=None, locator=None, logger=None)

Bases: widgetastic_patternfly4.dropdown.BaseGroupDropdown, widgetastic_patternfly4.dropdown.Dropdown

class widgetastic_patternfly4.dropdown.SplitButtonDropdown(parent, text=None, locator=None, logger=None)

Bases: widgetastic_patternfly4.dropdown.BaseSplitButtonDropdown, widgetastic_patternfly4.dropdown.Dropdown