def test(data): new_username = actions.random_str() actions.send_keys(create_user.username, new_username) actions.send_keys(create_user.password, '123456') actions.click(create_user.create_user_button) users.wait_for_table_to_load() users.assert_user_in_table(new_username)
def test(data): actions.navigate(data.env.url) actions.click(login.login_button) actions.send_keys(login.username_input, 'admin') actions.send_keys(login.password_input, 'admin') actions.click(login.login_button) actions.assert_element_text(index.title, 'Select a Project')
def test_config_modal_processes_less_than_1(data): test_builder.open_run_configurations_modal() actions.assert_element_value(test_run_config_modal.processes_input, '1') actions.clear_element(test_run_config_modal.processes_input) actions.send_keys(test_run_config_modal.processes_input, '0') actions.click(test_run_config_modal.run_button) common.assert_info_bar_message('Processes must be at least one')
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 test(data): actions.navigate(data.env.url+'tabs/') actions.send_keys('#urlInput', '/elements/') actions.click("#goButton") actions.verify_window_present_by_partial_title('Elem') # Elements golem_steps.assert_last_step_message("Verify window present by partial title 'Elem'") actions.verify_window_present_by_partial_title('Tab') # Tabs
def test_config_modal_processes_not_integer(data): actions.refresh_page() test_builder.open_run_configurations_modal() actions.clear_element(test_run_config_modal.processes_input) actions.send_keys(test_run_config_modal.processes_input, 'abc') actions.click(test_run_config_modal.run_button) common.assert_info_bar_message('Processes must be an integer')
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 test_create_project_with_invalid_name(data): actions.navigate(data.env.url) actions.click(index.create_project_button) actions.send_keys(index.project_name_input, 'project_test_$') actions.click(index.create_button) common.assert_error_message( 'Only letters, numbers and underscores are allowed')
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 test(data): actions.navigate(data.env.url+'tabs/') actions.send_keys('#urlInput', '/elements/') actions.click("#goButton") actions.clear_element('#urlInput') actions.send_keys('#urlInput', '/alert/') actions.click("#goButton") actions.switch_to_window_by_index(0) first_title = actions.get_window_title() actions.switch_to_window_by_index(1) second_title = actions.get_window_title() actions.switch_to_window_by_index(2) third_title = actions.get_window_title() actions.switch_to_window_by_index(0) # close third window by title actions.get_browser().close_window_by_title(third_title) actions.verify_amount_of_windows(2) actions.verify_title(first_title) # close first window by title, from the first window actions.get_browser().close_window_by_title(first_title) # second window is now active actions.verify_amount_of_windows(1) actions.verify_title(second_title) # try to close a window that is not present msg = "a window with title 'Incorrect Title' was not found" with expected_exception(Exception, msg): actions.get_browser().close_window_by_title('Incorrect Title')
def test(data): project_name = 'project_test_$' actions.click(index.create_project_button) actions.send_keys(index.project_name_input, project_name) actions.click(index.create_button) common.assert_error_message( 'Only letters, numbers and underscores are allowed')
def test_add_new_page_with_invalid_chars(data): actions.refresh_page() actions.click(test_builder.new_page_button) actions.send_keys(test_builder.new_page_modal_input, '$$invalid') actions.click(test_builder.new_page_modal_submit) common.assert_error_message( "Only letters, numbers and underscores are allowed") actions.refresh_page()
def test_config_modal_env_doesnt_exist(data): actions.refresh_page() test_builder.open_run_configurations_modal() actions.send_keys(test_run_config_modal.environments_input, 'not-existent-env') actions.click(test_run_config_modal.run_button) common.assert_info_bar_message( 'Environment not-existent-env does not exist for project test')
def test(data): actions.navigate(data.env.url + 'tabs/') actions.send_keys('#title', 'foo') actions.click('#goButtonCustom') actions.assert_amount_of_windows(2) actions.close_window_by_partial_url('tab/') golem_steps.assert_last_step_message("Close window by partial URL 'tab/'") actions.assert_amount_of_windows(1)
def test_rename_test_inline_invalid_chars(data): actions.refresh_page() actions.click(test_builder.test_name) actions.send_keys(test_builder.test_name_input, '??') actions.press_key(test_builder.test_name_input, 'TAB') common.assert_toast_message_is_displayed('Only letters, numbers and underscores are allowed') actions.refresh_page() actions.assert_element_text(test_builder.test_name, data.test)
def test_rename_test_inline_too_long(data): actions.refresh_page() actions.click(test_builder.test_name) actions.send_keys(test_builder.test_name_input, 'abcdefghij' * 14 + 'a') actions.press_key(test_builder.test_name_input, 'TAB') common.assert_toast_message_is_displayed('Maximum name length is 150 characters') actions.refresh_page() actions.assert_element_text(test_builder.test_name, data.test)
def test(data): project_name = actions.random_str(prefix='project_') actions.click(index.create_project_button) actions.wait_for_element_displayed(index.project_name_input) actions.send_keys(index.project_name_input, project_name) actions.click(index.create_button) actions.wait_for_element_not_displayed(index.create_button) index.assert_project_exists(project_name.replace(' ', '_'))
def test(data): actions.navigate(data.env.url+'elements/') element = ('id', 'input-one') actions.send_keys(element, 'test text') b = browser.get_browser() assert b.find(element).get_attribute('value') == 'test text' actions.clear_element(element) assert b.find(element).get_attribute('value') == ''
def test(data): actions.navigate(data.env.url) actions.send_keys(login.username_input, 'admin') actions.send_keys(login.password_input, 'incorrect password') actions.click(login.login_button) actions.take_screenshot('Verify the correct error message is shown') actions.assert_element_text(login.error_list, 'Username and password do not match')
def test(data): actions.navigate(data.env.url + 'tabs/') actions.send_keys('#title', 'lorem ipsum') actions.click('#goButtonCustom') actions.assert_amount_of_windows(2) actions.close_window_by_title('lorem ipsum') golem_steps.assert_last_step_message("Close window by title 'lorem ipsum'") actions.assert_amount_of_windows(1)
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_create_project_spaces_replaced_with_underscores(data): actions.navigate(data.env.url) project_name = actions.random_str(prefix='project ') actions.click(index.create_project_button) actions.wait_for_element_displayed(index.project_name_input) actions.send_keys(index.project_name_input, project_name) actions.click(index.create_button) actions.wait_for_element_not_displayed(index.create_button) assert index.project_is_present(project_name.replace(' ', '_'))
def test(data): actions.click(index.create_project_button) project_name = actions.random_str(prefix='project_') actions.send_keys(index.project_name_input, project_name) actions.click(index.create_button) actions.click(index.create_project_button) actions.send_keys(index.project_name_input, project_name) actions.click(index.create_button) common.assert_error_message('A project with that name already exists')
def test_create_project(data): actions.navigate(data.env.url) project_name = actions.random_str() actions.click(index.create_project_button) actions.wait_for_element_displayed(index.project_name_input) actions.send_keys(index.project_name_input, project_name) actions.click(index.create_button) actions.wait_for_element_not_displayed(index.create_button) assert index.project_is_present(project_name)
def test(data): actions.navigate(data.env.url + 'tabs/') actions.send_keys('#urlInput', '/elements/') actions.click("#goButton") actions.get_browser().switch_to_window_by_title( 'Web Playground - Elements') actions.verify_title('Web Playground - Elements') with expected_exception( Exception, "Window with title 'incorrect title' was not found"): actions.get_browser().switch_to_window_by_title('incorrect title')
def test(data): actions.navigate(data.env.url + 'tabs/') actions.send_keys('#urlInput', '/elements/') actions.click("#goButton") actions.switch_to_window_by_index(0) browser = actions.get_browser() second_handle = browser.window_handles[1] browser.close_window_switch_back(second_handle) actions.verify_title('Web Playground - Tabs') actions.verify_amount_of_windows(1)
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 test(data): input_one = '#input-one' actions.navigate(data.env.url + 'elements/') actions.send_keys(input_one, 'foo') actions.verify_element_value_is_not(input_one, 'bar') expected = "Verify element {} value is not 'bar'".format(input_one) golem_steps.assert_last_step_message(expected) actions.verify_element_value_is_not(input_one, 'foo') msg = ("expected element {} value to not be 'foo'".format(input_one)) golem_steps.assert_last_error(msg)
def test(data): tabs_url = data.env.url + 'tabs/' elements_url = data.env.url + 'elements/' actions.navigate(tabs_url) actions.send_keys('#urlInput', '/elements/') actions.click("#goButton") actions.verify_window_present_by_url(tabs_url) golem_steps.assert_last_step_message( "Verify window present by URL '{}'".format(tabs_url)) actions.verify_window_present_by_url(elements_url)
def test(data): actions.navigate(data.env.url+'tabs/') actions.send_keys('#urlInput', '/elements/') actions.click("#goButton") actions.switch_to_window_by_partial_title('Ele') golem_steps.assert_last_step_message("Switch to window with partial title 'Ele'") actions.verify_title('Web Playground - Elements') msg = "Window with partial title 'incorrect title' was not found" with expected_exception(Exception, msg): actions.switch_to_window_by_partial_title('incorrect title')