chrome.py (1413B)
1 import pytest 2 from support.context import using_context 3 from tests.support.asserts import assert_success 4 5 6 def get_window_handles(session): 7 return session.transport.send( 8 "GET", "session/{session_id}/window/handles".format(**vars(session)) 9 ) 10 11 12 @pytest.mark.allow_system_access 13 def test_basic(session): 14 with using_context(session, "chrome"): 15 response = get_window_handles(session) 16 assert_success(response, session.handles) 17 18 19 @pytest.mark.allow_system_access 20 def test_different_handles_than_content_scope(session): 21 response = get_window_handles(session) 22 content_handles = assert_success(response) 23 24 with using_context(session, "chrome"): 25 response = get_window_handles(session) 26 chrome_handles = assert_success(response) 27 28 assert chrome_handles != content_handles 29 assert len(chrome_handles) == 1 30 assert len(content_handles) == 1 31 32 33 @pytest.mark.allow_system_access 34 def test_multiple_windows_and_tabs(session): 35 session.new_window(type_hint="window") 36 session.new_window(type_hint="tab") 37 38 response = get_window_handles(session) 39 content_handles = assert_success(response) 40 41 with using_context(session, "chrome"): 42 response = get_window_handles(session) 43 chrome_handles = assert_success(response) 44 45 assert chrome_handles != content_handles 46 assert len(chrome_handles) == 2 47 assert len(content_handles) == 3