def test(data): actions.navigate(data.env.url + 'tabs/') actions.click('#openTab') actions.wait_for_window_present_by_title('Tab') assert actions.get_browser().get_window_index() == 0 actions.switch_to_window_by_index(1) assert actions.get_browser().get_window_index() == 1
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', timeout=5) assert actions.get_window_index() == 0 actions.switch_to_window_by_index(1) assert actions.get_window_index() == 1
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.click('#openTab') actions.wait_for_window_present_by_title('Tab') actions.switch_to_window_by_index(1) assert actions.get_window_index() == 1 actions.assert_title('Tab') actions.switch_to_first_window() golem_steps.assert_last_step_message('Switch to first window') assert actions.get_window_index() == 0 actions.assert_title('Web Playground - Tabs')
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): 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 + 'tabs/') # open two more tabs actions.send_keys('#title', 'SECOND TAB') actions.click('#goButtonCustom') actions.clear_element('#title') actions.send_keys('#title', 'THIRD TAB') actions.click('#goButtonCustom') # wait for the new tabs to load actions.wait_for_window_present_by_title('SECOND TAB', timeout=5) actions.wait_for_window_present_by_title('THIRD TAB', timeout=5) # switch to last tab and navigate to index actions.switch_to_window_by_index(2) assert actions.get_window_index() == 2 actions.navigate(data.env.url) # switch to first tab actions.switch_to_first_window() actions.assert_title('Web Playground - Tabs') # switch to last tab actions.switch_to_last_window() golem_steps.assert_last_step_message('Switch to last window') assert actions.get_window_index() == 2 actions.assert_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(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)
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(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)