def _rename_elem(elem_type, old_fullpath, new_fullpath): if elem_type == 'test': tree_ul = element(id='testCasesTree') elif elem_type == 'page': tree_ul = element(id='pagesTree') elif elem_type == 'suite': tree_ul = element(id='suitesTree') else: raise ('Error: elem_type must be in {}'.format( ['test', 'page', 'suite'])) split_path = old_fullpath.split('/') elem_name = split_path.pop() if split_path: _expand_tree_path(tree_ul, list(split_path)) full_dot_path = old_fullpath.replace('/', '.') selector = "li.tree-element[fullpath='{}']".format(full_dot_path) tree_elem = tree_ul.find(selector) rename_button = tree_elem.find( '.tree-element-buttons > button.rename-button') actions.click(rename_button) actions.wait(0.5) # TODO prompt_input = element('#promptModal #promptModalInput') actions.clear(prompt_input) actions.send_keys(prompt_input, new_fullpath) actions.click('#promptModal #prompSaveButton')
def add_action(action_name, where='test'): """adds an action using the autocomplete list""" if where == 'test': steps_section = element('div#testSteps') elif where == 'setup': steps_section = element('#setupSteps') if not steps_section.is_displayed(): actions.click('#showSetupLink>a') actions.wait(0.5) elif where == 'teardown': steps_section = element('#teardownSteps') if not steps_section.is_displayed(): actions.click('#showTeardownLink>a') actions.wait(0.5) # get last input in steps section inputs = steps_section.find_all('input.form-control.step-first-input') last_input = inputs[-1] # use the last empty input or add a new one if it's not empty new_action_input = None if not len(last_input.get_attribute('value')): new_action_input = last_input else: steps_section.find('button.add-step').click() inputs = steps_section.find_all('input.form-control.step-first-input') new_action_input = inputs[-1] # actions.click('#testSteps button.add-step') # action_inputs = elements("#testSteps .step-first-input") # last_input = action_inputs[-1] actions.send_keys(new_action_input, action_name) actions.press_key(new_action_input, 'DOWN') actions.press_key(new_action_input, 'ENTER')
def select_env(env_name): input_ = element(environments_input) for i in range(len(env_name)): actions.send_keys(input_, env_name[i]) actions.wait(0.1) actions.press_key(input_, 'DOWN') actions.press_key(input_, 'ENTER')
def select_browser(env_name): input_ = element(browser_input) for i in range(len(env_name)): actions.send_keys(input_, env_name[i]) actions.wait(0.1) actions.press_key(input_, 'DOWN') actions.press_key(input_, 'ENTER') actions.press_key(input_, 'TAB')
def test(data): actions.wait(1) suite_builder.assert_test_not_selected(data.test) suite_builder.select_test(data.test) suite_builder.assert_test_counter(selected=1) suite_builder.save_suite() actions.refresh_page() suite_builder.assert_test_selected(data.test)
def test(data): actions.wait(2) actions.press_key(suite_builder.browsers_input, 'SPACE') suite_builder.assert_browser_suggestions([ 'chrome', 'chrome-remote', 'chrome-headless', 'chrome-remote-headless', 'edge', 'edge-remote', 'firefox', 'firefox-headless', 'firefox-remote', 'firefox-remote-headless', 'ie', 'ie-remote', 'opera', 'opera-remote', 'browser001' ])
def test(data): actions.send_keys(suite_builder.environments_input, 'not-existent') actions.wait(0.5) actions.click(suite_builder.save_button) common.assert_toast_message_is_displayed( 'Environment not-existent does not exist for project test') actions.refresh_page() actions.assert_alert_present() actions.accept_alert() actions.assert_element_value(suite_builder.environments_input, '')
def wait_until_execution_end(timeout=30): container = element('.report-container') script = 'return arguments[0].ExecutionReport.suiteFinished' actions.wait(3) for _ in range(timeout): suite_finished = actions.get_browser().execute_script( script, container) if suite_finished: return time.sleep(1) raise Exception('Timeout waiting for execution to end')
def test(data): url = data.env.url + 'tabs/' # title = 'Web Playground - Tabs' actions.navigate(url) actions.send_keys('#title', 'lorem ipsum') actions.click('#goButtonCustom') actions.assert_window_present_by_partial_title('ground - Tabs') golem_steps.assert_last_step_message("Assert window present by partial title 'ground - Tabs'") actions.wait(1) actions.assert_window_present_by_partial_title('lorem') try: actions.assert_window_present_by_partial_title('incorrect') except AssertionError as e: expected = "There is no window present with partial title 'incorrect'".format(url) assert expected in e.args[0]
def test(data): actions.wait(1) actions.check_element(suite_builder.all_tests_checkbox) actions.send_keys(suite_builder.processes_input, 3) actions.refresh_page() actions.wait(1) actions.assert_alert_present() actions.accept_alert() actions.assert_element_value(suite_builder.processes_input, '1') actions.clear_element(suite_builder.processes_input) actions.send_keys(suite_builder.processes_input, 3) actions.refresh_page() actions.assert_alert_present() actions.dismiss_alert() suite_builder.save_suite() common.navigate_menu('Suites') actions.assert_title_contains(': Suites')
def _add_tree_element(elem_type, fullpath): if elem_type == 'test': tree_ul = element(id='testCasesTree') elif elem_type == 'page': tree_ul = element(id='pagesTree') elif elem_type == 'suite': tree_ul = element(id='suitesTree') else: raise('Error: elem_type must be in {}'.format(['test', 'page', 'suite'])) split_path = fullpath.split('/') elem_name = split_path.pop() if split_path: _expand_tree_path(tree_ul, list(split_path)) dot_path = '.'.join(split_path) if split_path else '.' form_container = tree_ul.find("li.form-container[fullpath='{}']".format(dot_path)) form_container.find('a.new-element-link').click() add_elem_input = form_container.find('input.new-element-input') actions.send_keys(add_elem_input, elem_name) actions.press_key(add_elem_input, 'ENTER') actions.wait(0.5)
def add_step_to_test(test_name, action_name, params=None): """adds an action using the autocomplete list""" # get last step test_container = test_function_section(test_name) steps = test_container.find_all('div.step') last_step = steps[-1] # if the last action input is not empty, add a new one if last_step.find('input.step-first-input').value: test_container.find('button.add-step').click() steps = test_container.find_all('div.step') last_step = steps[-1] action_input = last_step.find('input.step-first-input') for i in range(len(action_name)): action_input.send_keys(action_name[i]) actions.wait(0.1) actions.press_key(action_input, 'DOWN') actions.press_key(action_input, 'ENTER') # fill in each param if params: param_inputs = last_step.find_all('input.parameter-input') for i, param in enumerate(params): param_inputs[i].send_keys(param)
def add_action(action_name, params=[], where='test'): """adds an action using the autocomplete list""" if where == 'test': steps_section = element('div#testSteps') elif where == 'setup': steps_section = element('#setupSteps', wait_displayed=False) if not steps_section.is_displayed(): actions.click('#showSetupLink>a') actions.wait(0.5) elif where == 'teardown': steps_section = element('#teardownSteps', wait_displayed=False) if not steps_section.is_displayed(): actions.click('#showTeardownLink>a') actions.wait(0.5) # get last step steps = steps_section.find_all('div.step') step = steps[-1] # if the last action input is not empty, add a new one if step.find('input.step-first-input').value: steps_section.find('button.add-step').click() steps = steps_section.find_all('div.step') step = steps[-1] action_input = step.find('input.step-first-input') for i in range(len(action_name)): action_input.send_keys(action_name[i]) actions.wait(0.1) actions.press_key(action_input, 'DOWN') actions.press_key(action_input, 'ENTER') # fill in each param if params: param_inputs = step.find_all('input.parameter-input') for i, param in enumerate(params): param_inputs[i].send_keys(param)
def test(data): actions.navigate(data.env.url + 'drag-and-drop/') actions.drag_and_drop(('id', 'airplane'), ('id', 'target2')) actions.wait(5)
def expand_test(test_file, test_name): test_row_by_full_test_name(test_file, test_name).click() actions.wait(1)
def test_press_key(data): actions.navigate(data.env.url + 'elements/') element = actions.get_browser().find('#input-one') element.press_key('NUMPAD2') actions.wait(0.5) actions.verify_element_text('#input-one-input-result', 'Welcome 2')