def assert_key_from_product(self, name, product, repo=None): """Assert the key association after deletion from product tab.""" nav = Navigator(self.browser) nav.go_to_products() self.wait_for_ajax() prd_element = self.search_entity(product, locators["prd.select"], katello=True) if prd_element: prd_element.click() self.wait_for_ajax() if repo is not None: self.click(tab_locators["prd.tab_repos"]) strategy = locators["repo.select"][0] value = locators["repo.select"][1] self.click((strategy, value % repo)) self.click(locators["repo.gpg_key_edit"]) element = Select(self.find_element(locators["repo.gpg_key_update"])).first_selected_option.text if element == "": return None else: raise UIError('GPGKey "{0}" is still assoc with selected repo'.format(name)) else: self.click(tab_locators["prd.tab_details"]) self.click(locators["prd.gpg_key_edit"]) element = Select(self.find_element(locators["prd.gpg_key_update"])).first_selected_option.text if element == "": return None else: raise UIError('GPG key "{0}" is still assoc with product'.format(name)) else: raise UIError('Could not find the product "{0}"'.format(product))
def search(self, name): """ Searches existing partition table from UI """ nav = Navigator(self.browser) nav.go_to_partition_tables() element = self.search_entity(name, locators["ptable.ptable_name"]) return element
def search(self, name): """ Searches existing medium from UI """ nav = Navigator(self.browser) nav.go_to_installation_media() element = self.search_entity(name, locators["medium.medium_name"]) return element
def search(self, name): """ Searches existing domain from UI """ nav = Navigator(self.browser) nav.go_to_domains() element = self.search_entity(name, locators["domain.domain_description"]) return element
def logout(self): """ Logout user from UI """ if self.find_element(locators["login.gravatar"]): nav = Navigator(self.browser) nav.go_to_sign_out()
def search(self, name): """Searches existing template from UI""" self.scroll_page() nav = Navigator(self.browser) nav.go_to_provisioning_templates() element = self.search_entity(name, locators["provision.template_select"]) return element
def search(self, name): """ Searches existing architecture from UI """ nav = Navigator(self.browser) nav.go_to_architectures() element = self.search_entity(name, locators['arch.arch_name']) return element
def search(self, name): """ Searches existing operating system from UI """ nav = Navigator(self.browser) nav.go_to_operating_systems() element = self.search_entity(name, locators["operatingsys.operatingsys_name"]) return element
def search(self, name): """ Searches existing env from UI """ nav = Navigator(self.browser) nav.go_to_environments() element = self.search_entity(name, locators["env.env_name"]) return element
def search(self, name, search_key): """ Searches existing user from UI """ nav = Navigator(self.browser) nav.go_to_users() element = self.search_entity(name, locators["users.user"], search_key=search_key) return element
def search(self, name): """ Searches existing operating system from UI """ nav = Navigator(self.browser) nav.go_to_operating_systems() element = self.search_entity( name, locators['operatingsys.operatingsys_name']) return element
def search(self, name): """ Searches existing domain from UI """ nav = Navigator(self.browser) nav.go_to_domains() element = self.search_entity(name, locators['domain.domain_description']) return element
def logout(self): """Logout user from UI""" # Scroll to top self.browser.execute_script('window.scroll(0, 0)') if self.wait_until_element(locators["login.gravatar"]) is None: raise UINoSuchElementError( "could not find login.gravatar to sign out") nav = Navigator(self.browser) nav.go_to_sign_out() self.wait_for_ajax()
def logout(self): """ Logout user from UI """ if self.find_element(locators["login.gravatar"]): nav = Navigator(self.browser) nav.go_to_sign_out() else: raise Exception( "could not find login.gravatar to sign out")
def logout(self): """ Logout user from UI """ if self.find_element(locators["login.gravatar"]) is None: raise UINoSuchElementError( "could not find login.gravatar to sign out") nav = Navigator(self.browser) nav.go_to_sign_out() self.wait_for_ajax()
def setUp(self): super(ContentEnvironment, self).setUp() # Make sure to use the Class' org_name instance if ContentEnvironment.org_name is None: ContentEnvironment.org_name = generate_name(8, 8) login = Login(self.browser) nav = Navigator(self.browser) org = Org(self.browser) login.login(self.katello_user, self.katello_passwd) nav.go_to_org() org.create(ContentEnvironment.org_name) login.logout()
def setUp(self): super(ActivationKey, self).setUp() # Make sure to use the Class' org_name instance if ActivationKey.org_name is None: ActivationKey.org_name = generate_name(8, 8) login = Login(self.browser) nav = Navigator(self.browser) org = Org(self.browser) login.login(self.katello_user, self.katello_passwd) nav.go_to_org() org.create(ActivationKey.org_name) login.logout()
def test_positive_register_client_to_rhai(self): """Check client registration to redhat-access-insights service. :id: f3aefdb3-ac99-402d-afd9-e53e9ee1e8d7 :expectedresults: Registered client should appear in the Systems sub- menu of Red Hat Access Insights """ # Register a VM to Access Insights Service with VirtualMachine(distro=DISTRO_RHEL6) as vm: try: vm.configure_rhai_client(self.ak_name, self.org_label, DISTRO_RHEL6) with Session(self) as session: # view clients registered to Red Hat Access Insights session.nav.go_to_select_org(self.org_name) Navigator(self.browser).go_to_insights_inventory() result = self.rhai.view_registered_systems() self.assertIn("1", result, 'Registered clients are not listed') finally: vm.get( '/var/log/redhat-access-insights/' 'redhat-access-insights.log', './insights_client_registration.log')
def test_positive_register_client_to_rhai(self): """Check client registration to redhat-access-insights service. @Feature: RHEL client registration to rhai @Assert: Registered client should appear in the Systems sub-menu of Red Hat Access Insights """ # Register a VM to Access Insights Service with VirtualMachine(distro='rhel67') as vm: try: vm.configure_rhai_client(self.ak_name, self.org_label, 'rhel67') with Session(self.browser) as session: # view clients registered to Red Hat Access Insights session.nav.go_to_select_org(self.org_name) Navigator(self.browser).go_to_insights_systems() result = self.rhai.view_registered_systems() self.assertIn("1", result, 'Registered clients are not listed') finally: vm.get('/var/log/redhat-access-insights/' 'redhat-access-insights.log', './insights_client_registration.log')
def search(self, name): """ Searches existing hostgroup from UI """ Navigator(self.browser).go_to_host_groups() element = self.search_entity(name, locators["hostgroups.hostgroup"]) return element
def search(self, name): """ Searches existing puppet-classes from UI """ Navigator(self.browser).go_to_puppet_classes() self.wait_for_ajax() element = self.search_entity(name, locators["puppetclass.select_name"]) return element
def assert_key_from_product(self, name, product, repo=None): """ Assert the key association after deletion from product tab """ nav = Navigator(self.browser) nav.go_to_products() self.wait_for_ajax() prd_element = self.search_entity(product, locators["prd.select"], katello=True) if prd_element: prd_element.click() self.wait_for_ajax() if repo is not None: self.wait_until_element(tab_locators["prd.tab_repos"]).click() strategy = locators["repo.select"][0] value = locators["repo.select"][1] self.wait_until_element((strategy, value % repo)).click() self.wait_for_ajax() self.wait_until_element(locators["repo.gpg_key_edit"]).click() self.wait_for_ajax() element = Select(self.find_element (locators["repo.gpg_key_update"] )).first_selected_option.text if element == '': return None else: raise Exception( "GPGKey '%s' is still assoc with selected repo" % name) else: self.wait_until_element(tab_locators ["prd.tab_details"]).click() self.wait_for_ajax() self.wait_until_element(locators["prd.gpg_key_edit"]).click() self.wait_for_ajax() element = Select(self.find_element (locators["prd.gpg_key_update"] )).first_selected_option.text if element == '': return None else: raise Exception( "GPG key '%s' is still assoc with product" % name) else: raise Exception( "Couldn't find the product '%s'" % product)
def assert_key_from_product(self, name, product, repo=None): """ Assert the key association after deletion from product tab """ nav = Navigator(self.browser) nav.go_to_products() self.wait_for_ajax() prd_element = self.search_entity(product, locators["prd.select"], katello=True) if prd_element: prd_element.click() self.wait_for_ajax() if repo is not None: self.wait_until_element(tab_locators["prd.tab_repos"]).click() strategy = locators["repo.select"][0] value = locators["repo.select"][1] self.wait_until_element((strategy, value % repo)).click() self.wait_for_ajax() self.wait_until_element(locators["repo.gpg_key_edit"]).click() self.wait_for_ajax() element = Select( self.find_element(locators["repo.gpg_key_update"]) ).first_selected_option.text if element == '': return None else: raise Exception( "GPGKey '%s' is still assoc with selected repo" % name) else: self.wait_until_element( tab_locators["prd.tab_details"]).click() self.wait_for_ajax() self.wait_until_element(locators["prd.gpg_key_edit"]).click() self.wait_for_ajax() element = Select( self.find_element(locators["prd.gpg_key_update"]) ).first_selected_option.text if element == '': return None else: raise Exception( "GPG key '%s' is still assoc with product" % name) else: raise Exception("Couldn't find the product '%s'" % product)
def execute_bulk_package_action(self, name, action_name, action_type='package', action_value=None, action_via='katello_agent', org_name=None): """Execute remote package action on a host collection :param name: hostcollection name to remotely execute package action on :param action_name: remote action to execute. Can be one of 4: 'update all', 'install', 'update', 'remove' :param action_type: type of package. can be one of 2: 'package' or 'package_group' :param action_value: Package or package group name to remotely install/update/remove (depending on `action_name`) :param action_via: the way to perform the action. Can be one of 3: 'katello_agent', 'remote_execution', 'remote_execution_custom' :param org_name: The name of the organization for context, it is an optional param since org can be previously selected on session :raise: UIError if remote task finished by timeout :return: Returns a string containing task status """ if action_name != 'update all' and not action_value: raise AttributeError('package or group name is required') if org_name: Navigator(self.browser).go_to_select_org(org_name, force=False) self.search_and_click(name) self.click(locators['hostcollection.collection_actions.packages']) if action_value: type_loc = "contenthost.bulk_actions.{0}_type".format(action_type) self.click(locators[type_loc]) self.assign_value( locators['contenthost.bulk_actions.package_name_input'], action_value) strategy, action_link_locator_path = locators[ 'contenthost.bulk_actions.via_{0}'.format(action_via)] action_link_locator_path = action_link_locator_path % action_name action_link_locator = (strategy, action_link_locator_path) strategy, value = locators['contenthost.bulk_actions.action_dropdown'] self.click((strategy, value % action_link_locator_path)) self.click(action_link_locator) result = self.wait_until_element( locators['contenthost.bulk_actions.remote_action_scheduled'] ) # this alert box fades after 2 seconds if result is None: raise UIError('Timeout waiting for package action to schedule') self.click(locators["hostcollection.collection_actions.modal_dismiss"])
def delete(self, hostname, really=True): """Delete existing discovered hosts from UI""" Navigator(self.browser).go_to_discovered_hosts() self.delete_entity( hostname, really, locators['discoveredhosts.delete'], drop_locator=locators['discoveredhosts.dropdown'], )
def setUp(self): # noqa """We do want a new browser instance for every test.""" if not self.remote: if self.driver_name.lower() == 'firefox': self.browser = webdriver.Firefox() elif self.driver_name.lower() == 'chrome': self.browser = webdriver.Chrome() elif self.driver_name.lower() == 'ie': self.browser = webdriver.Ie() elif self.driver_name.lower() == 'phantomjs': service_args = ['--ignore-ssl-errors=true'] self.browser = webdriver.PhantomJS( service_args=service_args ) else: self.browser = webdriver.Remote() else: self.browser = SeleniumFactory().createWebDriver( job_name=self.id(), show_session_id=True) self.browser.maximize_window() self.browser.get(get_server_url()) # Library methods self.activationkey = ActivationKey(self.browser) self.architecture = Architecture(self.browser) self.compute_resource = ComputeResource(self.browser) self.configgroups = ConfigGroups(self.browser) self.contentenv = ContentEnvironment(self.browser) self.content_views = ContentViews(self.browser) self.domain = Domain(self.browser) self.environment = Environment(self.browser) self.gpgkey = GPGKey(self.browser) self.hardwaremodel = HardwareModel(self.browser) self.hostgroup = Hostgroup(self.browser) self.hosts = Hosts(self.browser) self.location = Location(self.browser) self.login = Login(self.browser) self.medium = Medium(self.browser) self.navigator = Navigator(self.browser) self.user = User(self.browser) self.operatingsys = OperatingSys(self.browser) self.org = Org(self.browser) self.partitiontable = PartitionTable(self.browser) self.puppetclasses = PuppetClasses(self.browser) self.products = Products(self.browser) self.repository = Repos(self.browser) self.role = Role(self.browser) self.settings = Settings(self.browser) self.subnet = Subnet(self.browser) self.subscriptions = Subscriptions(self.browser) self.sync = Sync(self.browser) self.syncplan = Syncplan(self.browser) self.systemgroup = SystemGroup(self.browser) self.template = Template(self.browser) self.user = User(self.browser) self.usergroup = UserGroup(self.browser)
def login(self, username, password, organization=None): """ Logins user from UI """ if self.wait_until_element(locators["login.username"]): self.field_update("login.username", username) self.field_update("login.password", password) self.find_element(common_locators["submit"]).click() if self.find_element(common_locators["notif.error"]): return if self.find_element(locators["location.new"]): loc = Location(self.browser) loc.create(generate_name()) if organization: nav = Navigator(self.browser) nav.go_to_select_org(organization)
def delete(self, name, really=False): """ Deletes existing hostgroup from UI """ Navigator(self.browser).go_to_host_groups() self.delete_entity(name, really, locators["hostgroups.hostgroup"], locators['hostgroups.delete'], drop_locator=locators["hostgroups.dropdown"])
def assert_key_from_product(self, key_name, product): """ Assert the key association after deletion from product tab """ nav = Navigator(self.browser) nav.go_to_products() prd_element = self.search_entity(product, locators["prd.select"], katello=True) if prd_element: prd_element.click() sleep_for_seconds(2) self.wait_until_element(tab_locators["prd.tab_details"]).click() element = self.find_element(locators["prd.gpg_key"]).get_attribute("innerHTML") if element is None: return None else: raise Exception("GPGKey '%s' is still associated with product" % key_name) else: raise Exception("Couldn't find the product '%s'" % product)
def search(self, name): """ Searches existing env from UI """ Navigator(self.browser).go_to_environments() if len(name) <= 30: element = self.search_entity(name, locators["env.env_name"]) else: element = self.search_entity( name, common_locators["select_filtered_entity"]) return element
def import_scap_client_puppet_classes(self): """Imports puppet-foreman_scap_client puppet classes.""" Navigator(self.browser).go_to_puppet_classes() self.click(locators['puppetclass.import']) # Checking if the scap client puppet classes are already imported if self.wait_until_element( locators['puppetclass.environment_default_check']): self.click(locators['puppetclass.environment_default_check']) self.click(locators['puppetclass.update']) else: self.click(locators['puppetclass.cancel'])
def search(self, name): """ Searches existing medium from UI """ Navigator(self.browser).go_to_installation_media() self.wait_for_ajax() if len(name) <= 30: element = self.search_entity(name, locators["medium.medium_name"]) else: element = self.search_entity( name, common_locators["select_filtered_entity"]) return element
def search(self, name, search_key=None): """ Searches existing operating system from UI """ Navigator(self.browser).go_to_operating_systems() if len(name) <= 30: element = self.search_entity( name, locators['operatingsys.operatingsys_name'], search_key) else: element = self.search_entity( name, common_locators['select_filtered_entity'], search_key) return element
def __init__(self, browser, user=None, password=None): self._login = Login(browser) self.browser = browser self.nav = Navigator(browser) self.password = password self.user = user if self.user is None: self.user = settings.server.admin_username if self.password is None: self.password = settings.server.admin_password
def login(self, username, password, organization=None, location=None): """Logins user from UI""" if self.wait_until_element(locators['login.username']): self.assign_value(locators['login.username'], username) self.assign_value(locators['login.password'], password) self.click(common_locators['submit']) if self.find_element(common_locators['notif.error']): return if location: nav = Navigator(self.browser) nav.go_to_select_loc(location) if organization: nav = Navigator(self.browser) nav.go_to_select_org(organization)
def search(self, name): """ Searches existing config-groups from UI """ Navigator(self.browser).go_to_config_groups() self.wait_for_ajax() if len(name) <= 30: element = self.search_entity(name, locators["config_groups.select_name"]) else: element = self.search_entity( name, common_locators["select_filtered_entity"]) return element
def __init__(self, browser, user=None, password=None): self._login = Login(browser) self.browser = browser self.nav = Navigator(browser) self.password = password self.user = user if self.user is None: self.user = getattr(self.browser, 'foreman_user', settings.server.admin_username) if self.password is None: self.password = getattr(self.browser, 'foreman_password', settings.server.admin_password)
def __init__(self, browser, user=None, password=None): self.browser = browser self._login = Login(browser) self.nav = Navigator(browser) if user is None: self.user = conf.properties['foreman.admin.username'] else: self.user = user if password is None: self.password = conf.properties['foreman.admin.password'] else: self.password = password
def search(self, description, timeout=None): """ Searches existing domain from UI """ Navigator(self.browser).go_to_domains() self.wait_for_ajax() if len(description) <= 30: element = self.search_entity(description, locators["domain.domain_description"], timeout=timeout) else: element = self.search_entity( description, common_locators["select_filtered_entity"], timeout=timeout) return element
def navigate_to_entity(self): """Navigate to Host Collection entity page""" Navigator.go_to_host_collections()