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 search(self, name, search_key): """ Searches existing user from UI """ Navigator(self.browser).go_to_users() self.wait_for_ajax() element = self.search_entity(name, locators["users.user"], search_key=search_key) return element
def setUp(self): """ 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("https://%s:%s" % (self.host, self.port)) # Library methods self.activationkey = ActivationKey(self.browser) self.architecture = Architecture(self.browser) self.contentenv = ContentEnvironment(self.browser) self.compute_resource = ComputeResource(self.browser) self.content_views = ContentViews(self.browser) self.domain = Domain(self.browser) self.environment = Environment(self.browser) self.gpgkey = GPGKey(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.products = Products(self.browser) self.repository = Repos(self.browser) self.role = Role(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 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 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 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 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 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 __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 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 search(self, element_name): """ Uses the search box to locate an element from a list of elements. """ Navigator(self.browser).go_to_gpg_keys() self.wait_for_ajax() element = None strategy, value = locators["gpgkey.key_name"] searchbox = self.wait_until_element(common_locators["kt_search"]) if searchbox: searchbox.clear() searchbox.send_keys(escape_search(element_name)) self.wait_for_ajax() self.wait_until_element( common_locators["kt_search_button"]).click() element = self.wait_until_element((strategy, value % element_name)) return element
def search(self, name, timeout=None): """Searches existing Hardware-Models from UI. :param str name: Hardware-Model's name to search. """ Navigator(self.browser).go_to_hardware_models() if len(name) <= 30: element = self.search_entity(name, locators["hwmodels.select_name"], timeout=timeout) else: element = self.search_entity( name, common_locators["select_filtered_entity"], timeout=timeout) 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 test_positive_unregister_client_from_rhai(self): """Verify that 'Unregister' a system from RHAI works correctly @Feature: If a system is unregistered from the RHAI web interface, then the system should not be able to use the service. @Assert: Once the system is unregistered from the RHAI web interface then the unregistered system should return `1` on running the service 'redhat-access-insights' """ # Register a VM to Access Insights Service with VirtualMachine(distro='rhel71') as vm: try: vm.configure_rhai_client(self.ak_name, self.org_label, 'rhel71') with Session(self.browser) as session: session.nav.go_to_select_org(self.org_name) Navigator(self.browser).go_to_insights_systems() # Click on the unregister icon 'X' in the table against the # registered system listed. strategy, value = locators['insights.unregister_system'] session.nav.click( (strategy, value % vm.hostname), wait_for_ajax=True, ajax_timeout=40, ) # Confirm selection for clicking on 'Yes' to unregister the # system session.nav.click( locators['insights.unregister_button'] ) self.browser.refresh() time.sleep(60) self.browser.refresh() result = vm.run('redhat-access-insights') self.assertEqual(result.return_code, 1, "System has not been unregistered") finally: vm.get('/var/log/redhat-access-insights/' 'redhat-access-insights.log', './insights_unregister.log')
def execute_bulk_errata_installation(self, name, errata_id, action_via='katello_agent', timeout=120, org_name=None): """Execute errata installation on a host collection :param name: host collection name to install errata on :param errata_id: errata id, e.g. 'RHEA-2012:0055' :param action_via: the way to perform the action. Can be one of 3: 'katello_agent', 'remote_execution', 'remote_execution_custom' :param timeout: Timeout in seconds for errata installation task to finish :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 org_name: Navigator(self.browser).go_to_select_org(org_name, force=False) self.click(self.search(name)) self.click(tab_locators['hostcollection.collection_actions']) self.click(locators['hostcollection.collection_actions.errata']) strategy, value = locators['hostcollection.errata.errata_select'] self.click((strategy, value % errata_id)) strategy, action_link_locator_path = locators[ 'contenthost.bulk_actions.errata.via_{0}'.format(action_via)] strategy, value = locators['contenthost.bulk_actions.action_dropdown'] self.click((strategy, value % action_link_locator_path)) self.click((strategy, action_link_locator_path)) result = self.wait_until_element( locators['contenthost.remote_action_finished'], timeout=timeout, ) if result is None: raise UIError('Timeout waiting for errata installation to finish') return result.get_attribute('type')
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 package_search(self, name, package_name, package_tab="installed"): """Search for package on specific content host :param name: Content Host name. :param package_name: Package name. :param package_tab: Search for either `installed` packages or `applicable` packages. :return: WebElement containing package information. """ if bz_bug_is_open(1495271): Navigator(self.browser).go_to_dashboard() self.click(self.search(name)) self.click(tab_locators['contenthost.tab_packages']) if package_tab == 'installed': self.click(tab_locators.contenthost.tab_packages.installed) elif package_tab == 'applicable': self.click(tab_locators.contenthost.tab_packages.applicable) self.assign_value(common_locators.kt_search, package_name) self.click(common_locators.kt_search_button) return self.wait_until_element( locators['contenthost.package_search_name'] % package_name)
def navigate_to_entity(self): """Navigate to Hosts entity page""" Navigator(self.browser).go_to_hosts()
def navigate_to_entity(self): """Navigate to Smart Variable entity page""" Navigator(self.browser).go_to_smart_variables()
def navigate_to_entity(self): """Navigate to User entity page""" Navigator(self.browser).go_to_users()
def navigate_to_entity(self): """Navigate to Environment entity page""" Navigator(self.browser).go_to_environments()
def navigate_to_entity(self): """Navigate to org entity page""" Navigator(self.browser).go_to_org()
def navigate_to_entity(self): """Navigate to Medium entity page""" Navigator(self.browser).go_to_installation_media()
def navigate_to_entity(self): """Navigate to Host Collection entity page""" Navigator(self.browser).go_to_host_collections()
def navigate_to_entity(self): """Navigate to Package entity page""" Navigator(self.browser).go_to_packages()
def navigate_to_entity(self): """Navigate to Locations entity page""" Navigator(self.browser).go_to_loc()
def navigate_to_entity(self): """Navigate to Role entity page""" Navigator(self.browser).go_to_roles()