def _add_ldap_filter(**args): common.open_url('ldapfilter', 'add') _type_ldap_filter_name(args['name']) _choose_ldap_server(args['server']) if 'username' in args and 'password' in args: _type_username_and_password(args['username'], args['password']) _type_ldap_filter_base_dn(args['base_dn']) if 'custom_filter' in args: _type_ldap_custom_filter(args['custom_filter']) if 'number_type' in args: _select_phone_number_type(args['number_type']) common.go_to_tab("Attributes") for field in args.get('display_name', []): _add_filter_display_name_field(field) for field in args.get('phone_number', []): _add_filter_phone_number_field(field) form.submit.submit_form()
def unsearch_line(): common.open_url("line") searchbox_id = "it-toolbar-search" text_input = world.browser.find_element_by_id(searchbox_id) text_input.clear() submit_button = world.browser.find_element_by_id("it-toolbar-subsearch") submit_button.click()
def create_or_replace_certificate(info): common.remove_all_elements('certificat', info['name']) common.open_url('certificat', 'add') input_name = world.browser.find_element_by_id('it-name') input_name.send_keys(info['name']) if 'autosigned' in info: checked = info['autosigned'] == "yes" Checkbox.from_id('it-autosigned').set_checked(checked) if 'certificate authority' in info: checked = info['certificate authority'] == "yes" Checkbox.from_id('it-is_ca').set_checked(checked) input_date = world.browser.find_element_by_id('it-validity-end') input_date.clear() date = datetime.datetime.now() if info['valid date in the future'] == "yes": date += datetime.timedelta(days=31) else: date -= datetime.timedelta(days=1) input_date.send_keys(date.strftime("%m/%d/%Y")) input_email = world.browser.find_element_by_id('it-subject-emailAddress') input_email.clear() input_email.send_keys(info['email'])
def set_accessibility_to_any_host(): common.open_url('phonebook_settings') multilist = form.PhonebookSettingsMultilist.from_id('accesslist') multilist.remove_all() multilist.add('0.0.0.0/1') multilist.add('128.0.0.0/1') form.submit.submit_form()
def when_i_create_a_trunkcustom_with_name_and_trunk(step, name): common.open_url('trunkcustom', 'add') input_name = world.browser.find_element_by_id('it-protocol-name', 'trunkcustom form not loaded') input_name.send_keys(name) input_interface = world.browser.find_element_by_id('it-protocol-interface', 'trunkcustom form not loaded') input_interface.send_keys('misdn//xivo') form.submit.submit_form()
def add_boss_secretary_filter(**data): common.open_url('callfilter', 'add') if 'entity' in data and data['entity']: type_callfilter_entity(data['entity']) type_callfilter_name(data['name']) type_callfilter_boss(data['boss']) add_secretary(data['secretary']) submit.submit_form()
def when_i_create_a_skill_rule(step, skill_rule_name): common.open_url('skill_rule', 'add') skill_rule_action_webi.type_skill_rule_name(skill_rule_name) skill_rule_config = step.hashes for skill_rule_element in skill_rule_config: rule = skill_rule_element['rule'] skill_rule_action_webi.add_rule(rule) form.submit.submit_form()
def _toggle_live_reload(state): common.open_url("general_settings") option = Checkbox.from_label("Live reload configuration") if state == "enable": option.check() else: option.uncheck() form.submit.submit_form()
def add_call_form_model(call_form_name, variables): common.remove_element_if_exist('sheet', call_form_name, column='Model') common.open_url('sheet', 'add') form.input.set_text_field_with_label('Name :', call_form_name) common.go_to_tab('Sheet') for variable in variables: _add_sheet_variable(variable) form.submit.submit_form()
def search_line_number(line_number): common.open_url("line") searchbox_id = "it-toolbar-search" text_input = world.browser.find_element_by_id(searchbox_id) text_input.clear() text_input.send_keys(line_number) submit_button = world.browser.find_element_by_id("it-toolbar-subsearch") submit_button.click()
def then_i_see_a_user_with_infos(step): user_expected_properties = step.hashes[0] fullname = user_expected_properties['fullname'] common.open_url('user', 'search', {'search': '%s' % fullname}) user_actual_properties = user_action_webi.get_user_list_entry(fullname) assert_that(fullname, equal_to(user_expected_properties['fullname'])) for user_field, user_value in user_expected_properties.iteritems(): assert_that(user_actual_properties[user_field], equal_to(user_value)) common.open_url('user', 'search', {'search': ''})
def when_i_rename_user(step, orig_firstname, orig_lastname, dest_firstname, dest_lastname): user_id = user_helper.find_user_id_with_firstname_lastname( orig_firstname, orig_lastname) ule_helper.delete_user_line_extension_with_firstname_lastname( dest_firstname, dest_lastname) common.open_url('user', 'edit', {'id': user_id}) user_action_webi.type_user_names(dest_firstname, dest_lastname) form.submit.submit_form()
def when_i_create_a_trunkcustom_with_name_and_trunk(step, name): common.open_url('trunkcustom', 'add') input_name = world.browser.find_element_by_id( 'it-protocol-name', 'trunkcustom form not loaded') input_name.send_keys(name) input_interface = world.browser.find_element_by_id( 'it-protocol-interface', 'trunkcustom form not loaded') input_interface.send_keys('misdn//xivo') form.submit.submit_form()
def when_i_create_configfiles_with_content(step, filename, content): common.open_url('configfiles', 'add') input_filename = world.browser.find_element_by_id('it-configfile-filename') input_filename.clear() input_filename.send_keys(filename) input_description = world.browser.find_element_by_id('it-configfile-description') input_description.clear() input_description.send_keys(content) form.submit.submit_form()
def then_the_outcall_1_has_the_extension_patterns(step, outcall_name): common.open_url('outcall', 'list') common.edit_line(outcall_name) common.go_to_tab('Exten') for outcall_extension in step.hashes: extension_pattern = outcall_extension['extension_pattern'] extension_pattern_input = outcall_action_webi.exten_line(extension_pattern).find_element_by_xpath(".//input[@name='dialpattern[exten][]']") assert_that(extension_pattern_input, not_none())
def _add_directory(name, uri, direct_match, delimiter=None, reverse_match=None): common.open_url('cti_directory', 'add') input.set_text_field_with_label("Name", name) if delimiter: input.set_text_field_with_label("Delimiter", delimiter) input.set_text_field_with_label("Direct match", direct_match) if reverse_match: input.set_text_field_with_label("Match reverse directories", reverse_match) select.set_select_field_with_label("URI", uri)
def add_or_replace_display(name, fields): if common.element_is_in_list('cti_display_filter', name): common.remove_line(name) common.open_url('cti_display_filter', 'add') _type_display_name(name) for title, field_type, display in fields: _add_display_field(title, field_type, display) submit.submit_form()
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 remove_call_limits(call_limits): common.open_url('general_iax') common.go_to_tab('Call limits') for call_limit in call_limits: lines = find_call_limit_lines(call_limit['address'], call_limit['netmask']) for line in lines: delete_button = line.find_element_by_xpath(".//a[@title='Delete this limit']") delete_button.click() form.submit.submit_form()
def update_plugin_list(url, check_confirmation=True): provd_general_action_webi.update_plugin_server_url(url) common.open_url('provd_plugin') world.browser.find_element_by_id('toolbar-bt-update').click() wait_time = 7 if check_confirmation: _check_for_confirmation_message(wait_time) else: time.sleep(wait_time)
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 then_i_see_user_with_username_group1_group2_has_a_function_key(step, firstname, lastname, extension): common.open_url('user', 'search', {'search': '%s %s' % (firstname, lastname)}) common.edit_line("%s %s" % (firstname, lastname)) common.go_to_tab('Func Keys') destination_field = world.browser.find_element_by_id('it-phonefunckey-custom-typeval-0') assert destination_field.get_attribute('value') == extension type_field = Select(world.browser.find_element_by_id('it-phonefunckey-type-0')) assert type_field.first_selected_option.text == "Customized" common.open_url('user', 'search', {'search': ''})
def when_i_edit_the_device_with_infos(step, device_id): common.open_url('device', 'edit', qry={'id': device_id}) device_infos = step.hashes[0] if 'plugin' in device_infos: device_action_webi.type_input('plugin', device_infos['plugin']) if 'template_id' in device_infos: device_action_webi.type_select('template_id', device_infos['template_id']) if 'description' in device_infos: device_action_webi.type_input('description', device_infos['description']) form.submit.submit_form()
def when_i_create_configfiles_with_content(step, filename, content): common.open_url('configfiles', 'add') input_filename = world.browser.find_element_by_id('it-configfile-filename') input_filename.clear() input_filename.send_keys(filename) input_description = world.browser.find_element_by_id( 'it-configfile-description') input_description.clear() input_description.send_keys(content) form.submit.submit_form()
def then_i_see_a_line_with_infos(step): expected_line = step.hashes[0] if 'device' in expected_line: expected_line[ 'device'] = True if expected_line['device'] == 'True' else False number = expected_line['number'] common.open_url('line', 'search', {'search': number}) actual_line = line_action_webi.get_line_list_entry(number) assert_that(actual_line, has_entries(expected_line)) common.open_url('user', 'search', {'search': ''})
def assign_filter_and_directories_to_context(context, filter_name, directories): if common.element_is_in_list('cti_direct_directory', context): common.remove_line(context) common.open_url('cti_direct_directory', 'add') select.set_select_field_with_label("Name", context) select.set_select_field_with_label("Display filter", filter_name) for directory in directories: add_directory_to_context(directory) submit.submit_form()
def update_sip_configuration(info): common.open_url('general_sip') common.go_to_tab('Security') checked = info['allow tls connections'] == "yes" Checkbox.from_label("Allow TLS connections").set_checked(checked) form.input.set_text_field_with_label("Listening address", info['listening address']) form.select.set_select_field_with_label("Server certificate", info['server certificate']) form.select.set_select_field_with_label("CA certificate", info['ca certificate']) form.submit.submit_form()
def given_i_have_a_sheet_model_with_custom_ui(step): sheet = step.hashes.pop() common.remove_element_if_exist('sheet', sheet['name']) common.open_url('sheet', 'add') form.input.set_text_field_with_label('Name :', sheet['name']) common.go_to_tab('Sheet') form.set_text_field_with_id('it-sheetactions-qtui', sheet['path to ui']) cti_helper.add_sheet_field(title='', display_type='form', default_value='', display_value='qtui') form.submit.submit_form()
def remove_call_limits(call_limits): common.open_url('general_iax') common.go_to_tab('Call limits') for call_limit in call_limits: lines = find_call_limit_lines(call_limit['address'], call_limit['netmask']) for line in lines: delete_button = line.find_element_by_xpath( ".//a[@title='Delete this limit']") delete_button.click() form.submit.submit_form()
def remove_directory(name): while common.element_is_in_list('cti_directory', name): common.remove_line(name) # Work around for directory associations that aren't deleted common.open_url('cti_direct_directory', 'list') try: common.edit_line('default') except Exception: pass # No default context configured else: submit.submit_form()
def when_i_remove_extension_patterns_from_outcall_1(step, outcall_name): common.open_url('outcall', 'list') common.edit_line(outcall_name) common.go_to_tab('Exten') for outcall_extension in step.hashes: extension_pattern = outcall_extension['extension_pattern'] delete_button = outcall_action_webi.exten_line(extension_pattern).find_element_by_id('lnk-del-row') delete_button.click() # Wait for the Javascript to remove the line time.sleep(1) form.submit.submit_form()
def set_call_form_model_on_event(call_form_name, event): common.open_url('sheetevent') for name, element in EVENT_ELEMENT_MAP.iteritems(): select_box = world.browser.find_element_by_id(element) if name == event: Select(select_box).select_by_visible_text(call_form_name) else: Select(select_box).select_by_index(0) form.submit.submit_form()
def given_there_is_a_profile_1_with_no_services_and_xlets(step, profile_name): profile_action_webi.delete_profile_if_exists(profile_name) common.open_url('profile', 'add') profile_action_webi.type_profile_names(profile_name) profile_action_webi.remove_all_services() common.go_to_tab('Xlets') cti_profile_config = step.hashes for cti_profile_element in cti_profile_config: xlet_name = cti_profile_element['xlet'] xlet_position = cti_profile_element.get('position', 'dock') profile_action_webi.add_xlet(xlet_name, xlet_position) form.submit.submit_form()
def when_i_add_a_sip_line_with_infos(step): for line_infos in step.hashes: common.open_url('line', 'add', {'proto': 'sip'}) world.id = _get_line_name() if 'context' in line_infos: context = line_infos['context'] form.select.set_select_field_with_id_containing( 'it-protocol-context', context) if 'custom_codecs' in line_infos: codec = line_infos['custom_codecs'] _add_custom_codec(codec) form.submit.submit_form()
def then_i_see_user_with_username_group1_group2_has_a_function_key( step, firstname, lastname, extension): common.open_url('user', 'search', {'search': '%s %s' % (firstname, lastname)}) common.edit_line("%s %s" % (firstname, lastname)) common.go_to_tab('Func Keys') destination_field = world.browser.find_element_by_id( 'it-phonefunckey-custom-typeval-0') assert destination_field.get_attribute('value') == extension type_field = Select( world.browser.find_element_by_id('it-phonefunckey-type-0')) assert type_field.first_selected_option.text == "Customized" common.open_url('user', 'search', {'search': ''})
def when_i_add_the_following_extension_patterns_to_the_outcall_1(step, outcall_name): common.open_url('outcall', 'list') common.edit_line(outcall_name) common.go_to_tab('Exten') for outcall_extension in step.hashes: add_button = world.browser.find_element_by_id('lnk-add-row', 'Can\'t add an exten') add_button.click() input_exten = world.browser.find_elements_by_xpath( "//table[@id='list_exten']//input[@name='dialpattern[exten][]']")[-1] input_exten.send_keys(outcall_extension['extension_pattern']) form.submit.submit_form()
def when_i_create_a_user(step): common.open_url('user', 'add') user_properties = step.hashes[0] user_action_webi.type_user_names(user_properties['firstname'], user_properties.get('lastname', '')) if 'number' in user_properties and 'context' in user_properties and 'protocol' in user_properties: user_action_webi.user_form_add_line( linenumber=user_properties['number'], context=user_properties['context'], protocol=user_properties['protocol'].upper(), device=user_properties.get('device', None), entity_displayname=user_properties.get('entity_displayname', None), ) form.submit.submit_form()
def then_the_profile_1_has_default_services_activated(step, profile_name): common.open_url('profile', 'list') common.edit_line(profile_name) time.sleep(world.timeout) # wait for the javascript to load expected_services = [ 'Enable DND', 'Unconditional transfer to a number', 'Transfer on busy', 'Transfer on no-answer', ] selected_services = profile_action_webi.selected_services() assert_that(selected_services, equal_to(expected_services))
def given_user_has_the_following_function_keys(step, firstname, lastname): common.open_url('user', 'search', {'search': '%s %s' % (firstname, lastname)}) common.edit_line("%s %s" % (firstname, lastname)) name_map = { 'Key': 'key_number', 'Type': 'key_type', 'Destination': 'destination', 'Label': 'label', 'Supervision': 'supervised', } for key_definition in step.hashes: key = dict((name_map[k], v) for k, v in key_definition.iteritems()) user_action_webi.type_func_key(**key) form.submit.submit_form()
def when_i_create_the_device_with_infos(step): common.open_url('device', 'add') device_infos = step.hashes[0] if 'mac' in device_infos: provd_helper.delete_device_with_mac(device_infos['mac']) device_action_webi.type_input('mac', device_infos['mac']) if 'ip' in device_infos: provd_helper.delete_device_with_ip(device_infos['ip']) device_action_webi.type_input('ip', device_infos['ip']) if 'plugin' in device_infos: device_action_webi.type_input('plugin', device_infos['plugin']) if 'template_id' in device_infos: device_action_webi.type_select('template_id', device_infos['template_id']) form.submit.submit_form()
def create_entry(entry): common.open_url('phonebook', 'add') display_name = _get_display_name_from_entry(entry) form.input.set_text_field_with_label("First Name", entry['first name']) form.input.set_text_field_with_label("Last Name", entry['last name']) form.input.set_text_field_with_label("Display name", display_name) if 'mobile' in entry: form.input.set_text_field_with_label("Mobile phone", entry['mobile']) common.go_to_tab("Office") form.input.set_text_field_with_label('Phone', entry.get('phone', '')) form.submit.submit_form()
def when_i_create_a_user(step): common.open_url('user', 'add') user_properties = step.hashes[0] user_action_webi.type_user_names(user_properties['firstname'], user_properties.get('lastname', '')) if 'number' in user_properties and 'context' in user_properties and 'protocol' in user_properties: user_action_webi.user_form_add_line( linenumber=user_properties['number'], context=user_properties['context'], protocol=user_properties['protocol'], device=user_properties.get('device', None), entity_displayname=user_properties.get('entity_displayname', None), ) form.submit.submit_form()
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_latest_plugin_line_and_name(plugin_prefix): common.open_url('provd_plugin') plugin_lines = common.find_lines(plugin_prefix) chosen = None chosen_name = '' for candidate in plugin_lines: candidate_name = candidate.find_element_by_xpath('.//td[2]').text if 'switchboard' in candidate_name: # exclude switchboard plugins, which are a special case continue if candidate_name > chosen_name: chosen = candidate chosen_name = candidate_name if not chosen: raise AssertionError('no plugin with name %s' % plugin_prefix) return chosen, chosen_name
def set_parking_config(config_map): common.open_url('extenfeatures') common.go_to_tab('Advanced', 'Parking') form.input.set_text_field_with_label('Extension', config_map['Extension']) form.select.set_select_field_with_label('Wait delay', config_map['Wait delay']) range_start = config_map['Range start'] range_end = config_map['Range end'] parking_range = '-'.join([range_start, range_end]) form.input.set_text_field_with_label('Extension to park calls', parking_range) enable_hints = config_map['Parkings hints'] == 'enabled' common.the_option_is_checked('Parkings hints', None, given=enable_hints) form.submit.submit_form()
def given_there_are_groups(step): for group in step.hashes: group_helper.delete_groups_with_number(group['exten']) group_helper.add_group(group['name'], group['exten'], group['context']) common.open_url('group', 'list', {'search': group['name']}) common.edit_line(group['name']) if 'ring seconds' in group: form.select.set_select_field_with_label( 'Ring time', '%s seconds' % group['ring seconds']) if 'noanswer' in group: common.go_to_tab('No answer') forward_dest_type, forward_dest_name = group['noanswer'].split( ':', 1) if forward_dest_type == 'group': form.select.set_select_field_with_id( 'it-dialaction-noanswer-actiontype', 'Group') form.select.set_select_field_with_id_containing( 'it-dialaction-noanswer-group-actionarg1', forward_dest_name) form.submit.submit_form() common.open_url('group', 'list', {'search': ''})
def given_i_set_the_following_options_in_line_1(step, line_number): line_id = line_helper.find_line_id_with_exten_context( line_number, 'default') common.open_url('line', 'edit', {'id': line_id}) for line_data in step.hashes: for key, value in line_data.iteritems(): if key == 'NAT': common.go_to_tab('General') form.select.set_select_field_with_label('NAT', value) elif key == 'IP addressing type': common.go_to_tab('Advanced') form.select.set_select_field_with_label( 'IP Addressing type', value) elif key == 'IP address': common.go_to_tab('Advanced') form.select.set_select_field_with_label( 'IP Addressing type', 'Static') form.input.set_text_field_with_label('IP address', value) else: raise Exception('%s is not a valid key' % key) form.submit.submit_form()
def given_there_is_group1_activated_in_extensions_page(step, option_label): common.open_url('extenfeatures') option = Checkbox.from_label(option_label) option.check() form.submit.submit_form()
def when_i_desactivate_dhcpd_server(step): common.open_url('dhcp') Checkbox.from_id('it-active').uncheck() form.submit.submit_form() commonconf_action_webi.webi_exec_commonconf()