def get_line_list_entry(search_number): line_tr = common.get_line(search_number) device_img = line_tr.find_element_by_class_name("col_identity").find_elements_by_tag_name("img")[1] device = "phone-green" in device_img.get_attribute("src") protocol = line_tr.find_element_by_class_name("col_protocol").text.lower() user = line_tr.find_element_by_class_name("col_user").text number = line_tr.find_element_by_class_name("col_number").text return {"device": device, "protocol": protocol, "user": user, "number": number}
def uninstall_plugins(plugin_name): common.open_url('provd_plugin') # uninstalling more than 1 plugins can't done in one step or selenium will raise a StaleElementReferenceException plugin_names = [] for plugin_line in common.find_lines(plugin_name): plugin_names.append(plugin_line.find_element_by_xpath('.//td[2]').text) for plugin_name in plugin_names: plugin_line = common.get_line(plugin_name) _uninstall_plugin(plugin_line)
def then_i_see_errors(step, profile_label): common.open_url('profile', 'list') table_line = common.get_line(profile_label) try: table_line.find_element_by_xpath(".//a[@title='Delete']") except NoSuchElementException: pass else: raise Exception('CTI profile %s should not be removable' % profile_label)
def get_user_list_entry(search_fullname): user_tr = common.get_line(search_fullname) fullname = user_tr.find_element_by_class_name('col_fullname').text provisioning_code = user_tr.find_element_by_class_name('col_provisioning_code').text number = user_tr.find_element_by_class_name('col_number').text protocol = user_tr.find_element_by_class_name('col_protocol').text return { 'fullname': fullname, 'provisioning_code': provisioning_code, 'number': number, 'protocol': protocol }
def get_user_list_entry(search_fullname): user_tr = common.get_line(search_fullname) fullname = user_tr.find_element_by_class_name('col_fullname').text provisioning_code = user_tr.find_element_by_class_name( 'col_provisioning_code').text number = user_tr.find_element_by_class_name('col_number').text protocol = user_tr.find_element_by_class_name('col_protocol').text return { 'fullname': fullname, 'provisioning_code': provisioning_code, 'number': number, 'protocol': protocol }
def get_line_list_entry(search_number): line_tr = common.get_line(search_number) device_img = line_tr.find_element_by_class_name( 'col_identity').find_elements_by_tag_name('img')[1] device = 'phone-green' in device_img.get_attribute('src') protocol = line_tr.find_element_by_class_name('col_protocol').text.lower() user = line_tr.find_element_by_class_name('col_user').text number = line_tr.find_element_by_class_name('col_number').text return { 'device': device, 'protocol': protocol, 'user': user, 'number': number, }
def set_privileges(username, privileges): common.open_url('admin_user', 'list') line = common.get_line(username) acl_button = line.find_element_by_xpath(".//a[@title='Rules']") acl_button.click() categories = set((x['module'], x['category']) for x in privileges) for module, category in categories: open_category(module, category) for privilege in privileges: set_privilege(privilege) form.submit.submit_form()
def get_nb_agents_in_group(agent_group): common.open_url('agent', 'list') table_line = common.get_line(agent_group) nb_agent = int(table_line.find_element_by_xpath(".//td[3]").text) return nb_agent
def get_agent_group_id(agent_group): common.open_url('agent', 'list') table_line = common.get_line(agent_group) agent_group_id = int(table_line.find_element_by_xpath(".//input[@name='agentgroups[]']").get_attribute('value')) return agent_group_id
def go_to_agent_group_page_list(agent_group): common.open_url('agent', 'list') table_line = common.get_line(agent_group) url_agent_group = table_line.find_element_by_xpath(".//a[@title='%s']" % agent_group) url_agent_group.click()
def select_agent_group_list(agent_group_list): for agent_group in agent_group_list: table_line = common.get_line(agent_group.strip()) element = table_line.find_element_by_xpath(".//input[@name='agentgroups[]']") element.click()
def when_i_download_backup_file(step, filename): common.open_url('backups') table_line = common.get_line(filename) download_link = table_line.find_element_by_xpath(".//a[@title='%s']" % filename) download_link.click()
def then_the_directory_has_the_uri(step, directory, uri): line = common.get_line(directory) cells = line.find_elements_by_tag_name("td") uri_cell = cells[2] assert uri_cell.text == uri
def _click_checkbox_for_line(extension): line_element = common.get_line(extension) checkbox = line_element.find_element_by_css_selector(".it-checkbox") checkbox.click()
def get_agent_group_id(agent_group): common.open_url("agent", "list") table_line = common.get_line(agent_group) agent_group_id = int(table_line.find_element_by_xpath(".//input[@name='agentgroups[]']").get_attribute("value")) return agent_group_id
def go_to_agent_group_page_list(agent_group): common.open_url("agent", "list") table_line = common.get_line(agent_group) url_agent_group = table_line.find_element_by_xpath(".//a[@title='%s']" % agent_group) url_agent_group.click()
def install_plugin(plugin_name): common.open_url('provd_plugin') plugin_line = common.get_line(plugin_name) _install_plugin(plugin_line)
def get_nb_agents_in_group(agent_group): common.open_url("agent", "list") table_line = common.get_line(agent_group) nb_agent = int(table_line.find_element_by_xpath(".//td[3]").text) return nb_agent