class ConfigManagementToolbar(View): """Toolbar""" refresh = Button(title='Refresh this page') configuration = Dropdown('Configuration') lifecycle = Dropdown('Lifecycle') policy = Dropdown('Policy') download = Dropdown(title='Download') view_selector = View.nested(ItemsToolBarViewSelector)
class request(WaitTab): # noqa TAB_NAME = 'Request' email = Input(name='requester__owner_email') first_name = Input(name='requester__owner_first_name') last_name = Input(name='requester__owner_last_name') notes = Input(name='requester__request_notes') manager_name = Input(name='requester__owner_manager') lookup = Button("Lookup") # button for looking up user name with ldap
class web_services(Tab): # noqa TAB_NAME = "Web Services" change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="ws_userid") password = Input(name="ws_password") confirm_password = Input(name="ws_verify") validate_button = Button("Validate")
class ipmi(Tab): # noqa TAB_NAME = "IPMI" change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="ipmi_userid") password = Input(name="ipmi_password") confirm_password = Input(name="ipmi_verify") validate_button = Button("Validate")
class HostDiscoverView(ComputeInfrastructureHostsView): """Discover View from Compute/Infrastructure/Hosts page.""" esx = Checkbox(name="discover_type_esx") ipmi = Checkbox(name="discover_type_ipmi") from_ip1 = Input(name="from_first") from_ip2 = Input(name="from_second") from_ip3 = Input(name="from_third") from_ip4 = Input(name="from_fourth") to_ip4 = Input(name="to_fourth") start_button = Button("Start") cancel_button = Button("Cancel") @property def is_displayed(self): return self.in_compute_infrastructure_hosts and self.title.text == "Hosts / Nodes Discovery"
class DatasourceAllToolbar(View): """The toolbar on the main page""" back = Button('Show {} Summary') policy = Dropdown('Policy') operations = Dropdown('Operations') download = Dropdown('Download') view_selector = View.nested(ItemsToolBarViewSelector)
class remote_login(Tab): # noqa TAB_NAME = "Remote Login" change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="remote_userid") password = Input(name="remote_password") confirm_password = Input(name="remote_verify") validate_button = Button("Validate")
class NodeEditTagsForm(NodeView): tag_category = BootstrapSelect('tag_cat') tag = BootstrapSelect('tag_add') # TODO: table for added tags with removal support # less than ideal button duplication between classes entities = View.nested(BaseNonInteractiveEntitiesView) save_button = Button('Save') reset_button = Button('Reset') cancel_button = Button('Cancel') @property def is_displayed(self): return ( self.in_cloud_instance and match_page(summary='Tag Assignment') and sel.is_displayed(resource_locator.format(self.context['object'].name)) )
class TasksView(BaseLoggedInPage): # Toolbar delete = Dropdown('Delete Tasks') # dropdown just has icon, use element title reload = Button(title=VersionPick({Version.lowest(): 'Reload the current display', '5.9': 'Refresh this page'})) @View.nested class tabs(View): # noqa # Extra Toolbar # Only on 'All' type tabs, but for access it doesn't make sense to access the tab for a # toolbar button cancel = Button(title='Cancel the selected task') # Form Buttons apply = Button('Apply') reset = Button('Reset') default = Button('Default') # Filters zone = BootstrapSelect(id='chosen_zone') period = BootstrapSelect(id='time_period') user = BootstrapSelect(id='user_choice') # This checkbox search_root captures all the filter options # It will break for status if/when there is second checkbox selection field added # It's the lowest level div with an id that captures the status checkboxes status = CheckboxSelect(search_root='tasks_options_div') state = BootstrapSelect(id='state_choice') @View.nested class mytasks(Tab): # noqa TAB_NAME = VersionPick({Version.lowest(): 'My VM and Container Analysis Tasks', '5.9': 'My Tasks'}) table = Table('//div[@id="gtl_div"]//table') @View.nested class myothertasks(Tab): # noqa TAB_NAME = VersionPick({'5.9': 'My Tasks', Version.lowest(): 'My Other UI Tasks'}) table = Table('//div[@id="gtl_div"]//table') @View.nested class alltasks(Tab): # noqa TAB_NAME = VersionPick({'5.9': 'All Tasks', Version.lowest(): "All VM and Container Analysis Tasks"}) table = Table('//div[@id="gtl_div"]//table') @View.nested class allothertasks(Tab): # noqa TAB_NAME = "All Other Tasks" table = Table('//div[@id="gtl_div"]//table') @property def is_displayed(self): return ( self.tabs.mytasks.is_displayed and self.tabs.myothertasks.is_displayed and self.tabs.alltasks.is_displayed and self.tabs.allothertasks.is_displayed)
class form(BasicProvisionFormView): # noqa """First page of provision form is image selection Second page of form is tabbed with nested views """ continue_button = Button( 'Continue') # Continue button on 1st page, image selection submit_button = Button('Submit') # Submit for 2nd page, tabular form cancel_button = Button('Cancel') def _select_template(self, template_name, provider_name): try: self.parent.paginator.find_row_on_pages( self.parent.image_table, name=template_name, provider=provider_name).click() # image was not found, therefore raise an exception except IndexError: raise ItemNotFound( 'Cannot find template "{}" for provider "{}"'.format( template_name, provider_name)) def before_fill(self, values): # Provision from image is a two part form, # this completes the image selection before the tabular parent form is filled template_name = values.get('template_name') provider_name = values.get('provider_name') if template_name is None or provider_name is None: logger.error( 'template_name "{}", or provider_name "{}" not passed to ' 'provisioning form', template_name, provider_name) # try to find the template anyway, even if values weren't passed self._select_template(template_name, provider_name) # workaround for provision table template select(template was not clicked) if self.continue_button.disabled: self.parent.sidebar.decrease_button.click() self._select_template(template_name, provider_name) self.continue_button.click() wait_for(self.browser.plugin.ensure_page_safe, delay=.1, num_sec=10) def after_fill(self, was_change): wait_for(self.browser.plugin.ensure_page_safe, delay=.1, num_sec=10)
class ProviderEditView(ProviderAddView): prov_type = Text(locator='//label[@name="emstype"]') # only in edit view vnc_start_port = Input('host_default_vnc_port_start') vnc_end_port = Input('host_default_vnc_port_end') flash = FlashMessages('.//div[@id="flash_msg_div"]/div[@id="flash_text_div" or ' 'contains(@class, "flash_text_div")]') save = Button('Save') reset = Button('Reset') cancel = Button('Cancel') @property def is_displayed(self): return self.logged_in_as_current_user and \ self.navigation.currently_selected == ['Compute', 'Infrastructure', 'Providers'] and \ self.title.text == 'Edit Infrastructure Provider'
class ConfigManagementToolbar(View): """Toolbar""" refresh = Button(title=VersionPick({Version.lowest(): 'Reload current display', '5.9': 'Refresh this page'})) configuration = Dropdown('Configuration') lifecycle = Dropdown('Lifecycle') policy = Dropdown('Policy') download = Dropdown(title='Download') view_selector = View.nested(ItemsToolBarViewSelector)
class ServerDetailsToolbar(View): """The toolbar on the details page""" monitoring = Dropdown('Monitoring') policy = Dropdown('Policy') power = Dropdown('Power') deployments = Dropdown('Deployments') drivers = Dropdown('JDBC Drivers') datasources = Dropdown('Datasources') download = Button(title='Download summary in PDF format')
class ProviderEditView(ProviderAddView): """ represents Provider Edit View """ prov_type = Text(locator='//label[@name="emstype"]') # only in edit view vnc_start_port = Input('host_default_vnc_port_start') vnc_end_port = Input('host_default_vnc_port_end') flash = FlashMessages('.//div[@id="flash_msg_div"]/div[@id="flash_text_div" or ' 'contains(@class, "flash_text_div")]') save = Button('Save') reset = Button('Reset') cancel = Button('Cancel') @property def is_displayed(self): return self.logged_in_as_current_user
class ProviderDetailsToolBar(View): """ represents provider toolbar and its controls """ monitoring = Dropdown(text='Monitoring') configuration = Dropdown(text='Configuration') reload = Button(title='Reload Current Display') policy = Dropdown(text='Policy') authentication = Dropdown(text='Authentication') view_selector = View.nested(DetailsToolBarViewSelector)
class HostDriftHistory(ComputeInfrastructureHostsView): breadcrumb = BreadCrumb(locator='.//ol[@class="breadcrumb"]') history_table = Table(locator='.//div[@id="main_div"]/table') analyze_button = Button( title="Select up to 10 timestamps for Drift Analysis") @property def is_displayed(self): return (self.in_compute_infrastructure_hosts and self.title.text == "Drift History" and self.history_table.is_displayed)
class DriftHistory(BaseLoggedInPage): title = Text('#explorer_title_text') breadcrumb = BreadCrumb(locator='.//ol[@class="breadcrumb"]') history_table = Table(locator='.//div[@id="main_div"]/table') analyze_button = Button( title="Select up to 10 timestamps for Drift Analysis") @property def is_displayed(self): return ("Drift History" in self.title.text and self.history_table.is_displayed)
class ConfigManagementEditForm(View): """Form to add a provider""" name = TextInput('name') provider_type = BootstrapSelect('provider_type') zone = TextInput('zone') url = TextInput('url') ssl = Checkbox('verify_ssl') username = TextInput('log_userid') password = TextInput('log_password') validate = Button('Validate')
class ProviderAddView(BaseLoggedInPage): """ represents Provider Add View """ title = Text('//div[@id="main-content"]//h1') name = Input('name') prov_type = BootstrapSelect(id='emstype') zone = Input('zone') add = Button('Add') cancel = Button('Cancel') @View.nested class endpoints(View): # NOQA # this is switchable view that gets replaced with concrete view. # it gets changed according to currently chosen provider type # look at cfme.common.provider.BaseProvider.create() method pass @property def is_displayed(self): return self.logged_in_as_current_user
class VMToolbar(View): """ Toolbar view for vms/instances collection destinations """ reload = Button(title='Reload current display') configuration = Dropdown('Configuration') policy = Dropdown('Policy') lifecycle = Dropdown('Lifecycle') power = Dropdown('Power Operations') # title download = Dropdown('Download') view_selector = View.nested(ItemsToolBarViewSelector)
class ProvidersEditTagsView(BaseLoggedInPage): """ Provider's Edit Tags view """ tag_category = BootstrapSelect('tag_cat') tag = BootstrapSelect('tag_add') chosen_tags = Table(locator='//div[@id="assignments_div"]/table') @View.nested class entities(BaseNonInteractiveEntitiesView): # noqa @property def entity_class(self): return ProviderEntity().pick(self.browser.product_version) save = Button('Save') reset = Button('Reset') cancel = Button('Cancel') @property def is_displayed(self): return False
class tabs(View): # noqa # Extra Toolbar # Only on 'All' type tabs, but for access it doesn't make sense to access the tab for a # toolbar button cancel = Button(title='Cancel the selected task') # Form Buttons apply = Button('Apply') reset = Button('Reset') default = Button('Default') # Filters zone = BootstrapSelect(id='chosen_zone') period = BootstrapSelect(id='time_period') user = BootstrapSelect(id='user_choice') # This checkbox search_root captures all the filter options # It will break for status if/when there is second checkbox selection field added # It's the lowest level div with an id that captures the status checkboxes status = CheckboxSelect(search_root='tasks_options_div') state = BootstrapSelect(id='state_choice') @View.nested class mytasks(Tab): # noqa TAB_NAME = "My VM and Container Analysis Tasks" table = Table(table_loc) @View.nested class myothertasks(Tab): # noqa TAB_NAME = "My Other UI Tasks" table = Table(table_loc) @View.nested class alltasks(Tab): # noqa TAB_NAME = "All VM and Container Analysis Tasks" table = Table(table_loc) @View.nested class allothertasks(Tab): # noqa TAB_NAME = "All Other Tasks" table = Table(table_loc)
class ProviderAddView(BaseLoggedInPage): title = Text('//div[@id="main-content"]//h1') name = Input('name') prov_type = BootstrapSelect(id='emstype') api_version = BootstrapSelect(id='api_version') # only for OpenStack zone = Input('zone') add = Button('Add') cancel = Button('Cancel') @View.nested class endpoints(View): # NOQA # this is switchable view that gets replaced with concrete view. # it gets changed according to currently chosen provider type # look at cfme.common.provider.BaseProvider.create() method pass @property def is_displayed(self): return self.logged_in_as_current_user and \ self.navigation.currently_selected == ['Compute', 'Infrastructure', 'Providers'] and \ self.title.text == 'Add New Infrastructure Provider'
class ProvidersManagePoliciesView(BaseLoggedInPage): """ Provider's Manage Policies view """ policies = VersionPick({ Version.lowest(): DynaTree('protect_treebox'), '5.7': BootstrapTreeview('protectbox') }) @View.nested class entities(BaseNonInteractiveEntitiesView): # noqa @property def entity_class(self): return ProviderEntity().pick(self.browser.product_version) save = Button('Save') reset = Button('Reset') cancel = Button('Cancel') @property def is_displayed(self): return False
class HostFormView(ComputeInfrastructureHostsView): # Info/Settings title = Text(".//div[@id='main-content']//h1") name = Input(name="name") hostname = Input(name="hostname") custom_ident = Input(name="custom_1") ipmi_address = Input(name="ipmi_address") mac_address = Input(name="mac_address") @View.nested class endpoints(View): # noqa @View.nested class default(Tab): # noqa change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="default_userid") password = Input(name="default_password") confirm_password = Input(name="default_verify") validate_button = Button("Validate") @View.nested class remote_login(Tab): # noqa TAB_NAME = "Remote Login" change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="remote_userid") password = Input(name="remote_password") confirm_password = Input(name="remote_verify") validate_button = Button("Validate") @View.nested class web_services(Tab): # noqa TAB_NAME = "Web Services" change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="ws_userid") password = Input(name="ws_password") confirm_password = Input(name="ws_verify") validate_button = Button("Validate") @View.nested class ipmi(Tab): # noqa TAB_NAME = "IPMI" change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="ipmi_userid") password = Input(name="ipmi_password") confirm_password = Input(name="ipmi_verify") validate_button = Button("Validate") cancel_button = Button("Cancel")
class form(BasicProvisionFormView): # noqa """First page of provision form is image selection Second page of form is tabbed with nested views """ continue_button = Button( 'Continue') # Continue button on 1st page, image selection submit_button = Button('Submit') # Submit for 2nd page, tabular form cancel_button = Button('Cancel') def _select_template(self, template_name, provider_name): try: row = self.parent.image_table.row(name=template_name, provider=provider_name) row.click() except IndexError: raise TemplateNotFound( 'Cannot find template "{}" for provider "{}"'.format( template_name, provider_name)) def before_fill(self, values): # Provision from image is a two part form, # this completes the image selection before the tabular parent form is filled template_name = values.get('template_name') provider_name = values.get('provider_name') if template_name is None or provider_name is None: logger.error( 'template_name "{}", or provider_name "{}" not passed to ' 'provisioning form', template_name, provider_name) # try to find the template anyway, even if values weren't passed self._select_template(template_name, provider_name) # workaround for provision table template select(template was not clicked) if self.continue_button.disabled: self.parent.sidebar.decrease_button.click() self._select_template(template_name, provider_name) self.continue_button.click() # TODO timing, wait_displayed is timing out and can't get it to stop in is_displayed sleep(3) self.flush_widget_cache()
class VMToolbar(View): """ Toolbar view for vms/instances collection destinations """ "Refresh this page" reload = Button(title=VersionPick({Version.lowest(): 'Reload current display', '5.9': 'Refresh this page'})) configuration = Dropdown('Configuration') policy = Dropdown('Policy') lifecycle = Dropdown('Lifecycle') power = Dropdown('Power Operations') # title download = Dropdown('Download') view_selector = View.nested(ItemsToolBarViewSelector)
class form(View): # noqa retirement_mode = BootstrapSelect(id='formMode') retirement_date = ConditionalSwitchableView(reference='retirement_mode') @retirement_date.register('Specific Date and Time', default=True) class RetirementDateSelectionView(View): datetime_select = TextInput(id='retirement_date_datepicker') @retirement_date.register('Time Delay from Now') class RetirementOffsetSelectionView(View): # TODO unique widget for these touchspin elements, with singular fill method # will allow for consistent fill of view.form months = TextInput(name='months') weeks = TextInput(name='weeks') days = TextInput(name='days') hours = TextInput(name='hours') retirement_offset_datetime = Text( locator='.//div[@id="retirement_date_result_div"]/input[@id="retirement_date"]') retirement_warning = BootstrapSelect(id='retirementWarning') entities = View.nested(BaseNonInteractiveEntitiesView) save = Button('Save') cancel = Button('Cancel')
class NodeDetailsView(NodeView): download = Button(name='download_view') @property def is_displayed(self): return (self.in_cloud_instance and match_page( summary='{} (Summary)'.format(self.context['object'].name))) @View.nested class properties(Accordion): # noqa tree = ManageIQTree() @View.nested class relationships(Accordion): # noqa tree = ManageIQTree()
class ConfigManagementAddForm(View): """Form to add a provider""" name = TextInput('name') provider_type = BootstrapSelect('provider_type') zone = TextInput('zone') url = TextInput('url') ssl = Checkbox('verify_ssl') username = VersionPick({Version.lowest(): TextInput('log_userid'), '5.9': TextInput('default_userid')}) password = VersionPick({Version.lowest(): TextInput('log_password'), '5.9': TextInput('default_password')}) confirm_password = TextInput('log_verify') validate = Button('Validate')