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): actions.navigate(data.env.url + 'elements/') actions.verify_title('Elements') try: actions.verify_title('incorrect title') except Exception as e: assert "expected title to be 'incorrect title' but was 'Elements'" in e.args[ 0]
def test(data): actions.navigate(data.env.url + 'elements/') actions.verify_title('Web Playground - Elements') golem_steps.assert_last_step_message( "Verify page title is 'Web Playground - Elements'") actions.verify_title('incorrect title') msg = "expected title to be 'incorrect title' but was 'Web Playground - Elements'" golem_steps.assert_last_error(msg)
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.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')
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.click('#openTab') actions.wait_for_window_present_by_title('Tab') actions.get_browser().switch_to_window_by_index(1) assert actions.get_window_index() == 1 actions.verify_title('Tab') actions.switch_to_first_window() assert actions.get_window_index() == 0 actions.verify_title('Web Playground - Tabs')
def test(data): actions.navigate(data.env.url + 'tabs/') actions.send_keys('#urlInput', '/elements/') actions.click("#goButton") actions.get_browser().switch_to_window_by_partial_url('elem') actions.verify_title('Web Playground - Elements') actions.get_browser().switch_to_window_by_partial_url('tab') actions.verify_title('Web Playground - Tabs') msg = "Window with partial URL 'xyz' was not found" with expected_exception(Exception, msg): actions.get_browser().switch_to_window_by_partial_url('xyz')
def test(data): actions.navigate(data.env.url + 'dynamic-elements/?delay=2') actions.verify_title('Web Playground - Dynamic Elements') actions.click('#change-title-button') actions.get_browser().wait_for_title('New Title', 4) actions.verify_title('New Title') actions.navigate(data.env.url + 'dynamic-elements/?delay=5') with expected_exception(Exception, "Timeout waiting for title to be 'New Title'"): actions.click('#change-title-button') actions.get_browser().wait_for_title('New Title', 2)
def test(data): actions.navigate(data.env.url+'dynamic-elements/?delay=3') actions.verify_title('Web Playground - Dynamic Elements') actions.click('#change-title-button') actions.wait_for_title('New Title', 5) golem_steps.assert_last_step_message("Wait for title to be 'New Title'") actions.verify_title('New Title') actions.navigate(data.env.url + 'dynamic-elements/?delay=5') with expected_exception(TimeoutException, "Timeout waiting for title to be 'New Title'"): actions.click('#change-title-button') actions.wait_for_title('New Title', 5)
def test(data): actions.navigate(data.env.url+'dynamic-elements/?delay=3') actions.click('#change-title-button') actions.verify_title('Web Playground - Dynamic Elements') actions.wait_for_title_is_not('Web Playground - Dynamic Elements', 4) actions.verify_title_is_not('Web Playground - Dynamic Elements') actions.navigate(data.env.url + 'dynamic-elements/?delay=5') msg = "Timeout waiting for title to not be 'Web Playground - Dynamic Elements'" with expected_exception(Exception, msg): actions.click('#change-title-button') actions.wait_for_title_is_not('Web Playground - Dynamic Elements', 3)
def test(data): actions.navigate(data.env.url+'tabs/') actions.click('#openTab') # firefox does not wait for tabs to load actions.wait_for_window_present_by_title('Tab') actions.switch_to_window_by_index(1) golem_steps.assert_last_step_message('Switch to window of index 1') assert actions.get_window_index() == 1 actions.verify_title('Tab') actions.switch_to_window_by_index(0) assert actions.get_window_index() == 0 actions.verify_title('Web Playground - Tabs')
def test(data): tabs_url = data.env.url + 'tabs/' elements_url = data.env.url + 'elements/' nonexistent_url = data.env.url + 'nonexistent-url/' actions.navigate(tabs_url) actions.send_keys('#urlInput', '/elements/') actions.click("#goButton") actions.get_browser().switch_to_window_by_url(elements_url) actions.verify_title('Web Playground - Elements') actions.get_browser().switch_to_window_by_url(tabs_url) actions.verify_title('Web Playground - Tabs') msg = "Window with URL '{}' was not found".format(nonexistent_url) with expected_exception(Exception, msg): actions.get_browser().switch_to_window_by_url(nonexistent_url)
def test(data): actions.navigate(data.env.url + 'tabs/') actions.send_keys('#title', 'SECOND TAB') actions.click('#goButtonCustom') actions.clear_element('#title') actions.send_keys('#title', 'THIRD TAB') actions.click('#goButtonCustom') actions.wait_for_window_present_by_title('SECOND TAB', timeout=10) actions.wait_for_window_present_by_title('THIRD TAB', timeout=10) actions.get_browser().switch_to_window_by_index(2) assert actions.get_window_index() == 2 actions.navigate(data.env.url) actions.switch_to_first_window() actions.verify_title('Web Playground - Tabs') actions.get_browser().switch_to_last_window() assert actions.get_window_index() == 2 actions.verify_title('Web Playground')
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(0) # close third window by index actions.get_browser().close_window_by_index(2) actions.verify_amount_of_windows(2) actions.verify_title(first_title) # close first window by index, from the first window actions.get_browser().close_window_by_index(0) actions.verify_amount_of_windows(1) # second window is now index 0 actions.verify_title(second_title)
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(2) actions.verify_title(third_title) actions.switch_to_previous_window() golem_steps.assert_last_step_message('Switch to previous window') actions.verify_title(second_title) actions.switch_to_previous_window() actions.verify_title(first_title) actions.switch_to_previous_window() actions.verify_title(third_title)
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) actions.get_browser().switch_to_next_window() actions.verify_title(second_title) actions.get_browser().switch_to_next_window() actions.verify_title(third_title) actions.get_browser().switch_to_next_window() actions.verify_title(first_title)