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 then_the_line_1_has_the_following_line_options(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 == 'Call limit': common.go_to_tab('IPBX Infos') assert line_action_webi.get_value_from_ipbx_infos_tab( 'call_limit') == value elif key == 'NAT': common.go_to_tab('General') nat_select = world.browser.find_element_by_label('NAT') nat_value = Select(nat_select).first_selected_option.text assert nat_value == value elif key == 'IP addressing type': common.go_to_tab('Advanced') ip_addressing_type_select = world.browser.find_element_by_label( 'IP Addressing type') ip_addressing_type_value = Select( ip_addressing_type_select).first_selected_option.text assert ip_addressing_type_value == value elif key == 'IP address': common.go_to_tab('Advanced') ip_address_input = world.browser.find_element_by_label( 'IP address') ip_address_value = ip_address_input.get_attribute('value') assert ip_address_value == value elif key == 'Caller ID': common.go_to_tab('IPBX Infos') assert line_action_webi.get_value_from_ipbx_infos_tab( 'callerid') == value else: raise Exception('%s is not a valid key' % key)
def get_value_from_ipbx_infos_tab(var_name): common.go_to_tab('IPBX Infos') value_cell = world.browser.find_element_by_xpath( "//table" "//tr[td[@class = 'td-left' and text() = '%s']]" "//td[@class = 'td-right']" % var_name) return value_cell.text
def type_func_key(key_type, destination, key_number=None, label=None, supervised=None): common.go_to_tab('Func Keys') add_funckey_line() current_line = find_func_key_line() key_type_field = find_key_type_field(current_line) key_type_field.select_by_visible_text(key_type) _fill_destination_field(key_type, current_line, destination) if key_number: key_number_field = find_key_number_field(current_line) key_number_field.select_by_visible_text(key_number) if label: label_field = find_key_label_field(current_line) label_field.send_keys(label) if supervised: supervision_field = find_key_supervision_field(current_line) supervision_field.select_by_visible_text(supervised)
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 change_key_order(pairs): common.go_to_tab('Func Keys') for old, new in pairs: current_line = world.browser.find_element_by_xpath( '''//tbody[@id='phonefunckey']/tr[%s]''' % old) number_field = Select( current_line.find_element_by_name('phonefunckey[fknum][]')) number_field.select_by_visible_text(new)
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 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_line(): common.go_to_tab('Lines') select_line = world.browser.find_element_by_xpath( "//table[@id='list_linefeatures']/tbody/tr//input[@id='linefeatures-number']" ) delete_button = select_line.find_element_by_xpath( "//a[@title='Delete this line']") delete_button.click() time.sleep(world.timeout)
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 fill_application_tab(queue): common.go_to_tab('Application') if CALLEE_TRANSFER in queue: callee_transfer = (queue[CALLEE_TRANSFER] == 'true') set_checkbox_with_id('it-queuefeatures-hitting-callee', callee_transfer) if CALLER_HANGUP in queue: caller_hangup = (queue[CALLER_HANGUP] == 'true') set_checkbox_with_id('it-queuefeatures-hitting-caller', caller_hangup)
def user_form_add_line(linenumber, context='default', protocol='SIP', device=None, entity_displayname=None): open_line_tab() if entity_displayname is not None: select_entity_with_displayname(entity_displayname) click_add_line_button() select_context(context) type_line_number(linenumber) select_protocol(protocol) if device is not None: select_device(device) common.go_to_tab('General')
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_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 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_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 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 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_a_new_line_to_a_user(step, firstname, lastname): _edit_user(firstname, lastname) user_properties = step.hashes[0] common.go_to_tab('Lines') user_action_webi.remove_line() 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 fill_general_tab(queue): common.go_to_tab('General') set_text_field_with_label('Name', queue['name']) set_text_field_with_label('Display name', queue['display name']) set_text_field_with_label('Number', queue['number']) context = context_helper.get_context_with_name(queue['context']) context_field_value = '%s (%s)' % (context.display_name, context.name) set_select_field_with_label('Context', context_field_value) if 'ring strategy' in queue: type_queue_ring_strategy(queue['ring strategy'])
def then_the_outcall_1_does_not_have_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'] try: outcall_action_webi.exten_line(extension_pattern) except NoSuchElementException: pass else: raise Exception('extension pattern %s unexpectedly found in outcall %s' % (outcall_extension, outcall_name))
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 fill_advanced_tab(queue): common.go_to_tab('Advanced') if REACH_TIMEOUT in queue: set_select_field_with_id('it-queue-timeout', queue[REACH_TIMEOUT]) if CALL_RETRY in queue: set_select_field_with_id('it-queue-retry', queue[CALL_RETRY]) if REASSIGN_DELAY in queue: set_select_field_with_id('it-queue-wrapuptime', queue[REASSIGN_DELAY]) if AUTOPAUSE_AGENTS in queue: autopause_agents = (queue[AUTOPAUSE_AGENTS] == 'true') set_checkbox_with_id('it-queue-autopause', autopause_agents)
def fill_advanced_tab(queue): common.go_to_tab('Advanced') if REACH_TIMEOUT in queue: set_select_field_with_id('it-queue-timeout', queue[REACH_TIMEOUT]) if CALL_RETRY in queue: set_select_field_with_id('it-queue-retry', queue[CALL_RETRY]) if REASSIGN_DELAY in queue: set_select_field_with_id('it-queue-wrapuptime', queue[REASSIGN_DELAY]) if AUTOPAUSE_AGENTS in queue: autopause_agents = 'Yes' if (queue[AUTOPAUSE_AGENTS] == 'true') else 'No' set_select_field_with_id('it-queue-autopause', autopause_agents)
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_user_has_a_dialaction(step, fullname, event, dialaction, destination): _edit_user(*fullname.split(' ', 1)) common.go_to_tab('No answer') if event == 'No answer': action_type = 'noanswer' elif event == 'Busy': action_type = 'busy' else: raise NotImplementedError('%s dialaction is not implemented' % event) if dialaction != 'User': raise NotImplementedError('%s dialaction destination is not implemented' % destination) action_type_id = 'it-dialaction-%s-actiontype' % action_type action_destination_id = 'it-dialaction-%s-user-actionarg1' % action_type _select(action_type_id, dialaction) _select(action_destination_id, destination) 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_user_has_a_dialaction(step, fullname, event, dialaction, destination): _edit_user(*fullname.split(' ', 1)) common.go_to_tab('No answer') if event == 'No answer': action_type = 'noanswer' elif event == 'Busy': action_type = 'busy' else: raise NotImplementedError('%s dialaction is not implemented' % event) if dialaction != 'User': raise NotImplementedError( '%s dialaction destination is not implemented' % destination) action_type_id = 'it-dialaction-%s-actiontype' % action_type action_destination_id = 'it-dialaction-%s-user-actionarg1' % action_type _select(action_type_id, dialaction) _select(action_destination_id, destination) form.submit.submit_form()
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 then_the_user_group1_has_the_following_func_keys(step, user): common.open_url('user', 'search', {'search': user}) common.edit_line(user) common.go_to_tab('Func Keys') for line_number, line in enumerate(step.hashes, 1): _check_func_key(line, line_number)
def _go_to_call_limits_form(): common.open_url('general_iax') common.go_to_tab('Call limits')
def _get_shrink_caller_id_option(): common.open_url('general_iax') common.go_to_tab('Advanced') option = Checkbox.from_label('Shrink CallerID') return option
def _get_srv_lookup_option(): common.open_url('general_iax') common.go_to_tab('Default') option = Checkbox.from_label('SRV lookup') return option
def get_value_from_ipbx_infos_tab(var_name): common.go_to_tab("IPBX Infos") value_cell = world.browser.find_element_by_xpath( "//table" "//tr[td[@class = 'td-left' and text() = '%s']]" "//td[@class = 'td-right']" % var_name ) return value_cell.text
def remove_agents_from_queue(agents): common.go_to_tab('Members') pane = ListPane.from_id('agentlist') for agent in agents: pane.remove_contains(agent)
def find_call_limit_lines(destination=None, netmask=None, limit=None): common.open_url('general_iax') common.go_to_tab('Call limits') xpath = _xpath_call_limit_line(destination, netmask, limit) lines = world.browser.find_elements_by_xpath(xpath) return lines
def i_go_on_the_general_settings_sip_protocol_page_tab(step, tab): common.open_url('general_sip') common.go_to_tab(tab)
def remove_closed_schedule(schedule_index): common.go_to_tab('Closed hours') _remove('closed', schedule_index)
def add_agents_to_queue(agents): common.go_to_tab('Members') pane = ListPane.from_id('agentlist') for agent in agents: pane.add_contains(agent)
def when_i_add_xlet_to_profile(step, xlet_name, profile_name): common.open_url('profile', 'list') common.edit_line(profile_name) common.go_to_tab('Xlets') profile_action_webi.add_xlet(xlet_name) form.submit.submit_form()