Bug 1652973 - [wdspec] Move close() method of webdriver client into the Window class. r=jgraham

Differential Revision: https://phabricator.services.mozilla.com/D83799
This commit is contained in:
Henrik Skupin 2020-07-17 16:36:06 +00:00
parent d87d25b173
commit e5d59335ce
7 changed files with 15 additions and 15 deletions

View File

@ -242,6 +242,15 @@ class Window(object):
def __init__(self, session):
self.session = session
@command
def close(self):
handles = self.session.send_session_command("DELETE", "window")
if handles is not None and len(handles) == 0:
# With no more open top-level browsing contexts, the session is closed.
self.session.session_id = None
return handles
@property
@command
def rect(self):
@ -569,15 +578,6 @@ class Session(object):
return self.send_session_command("POST", url, body)
@command
def close(self):
handles = self.send_session_command("DELETE", "window")
if handles is not None and len(handles) == 0:
# With no more open top-level browsing contexts, the session is closed.
self.session_id = None
return handles
@property
@command
def handles(self):

View File

@ -12,7 +12,7 @@ def fixture_session(capabilities, session, create_window):
yield session
try:
session.close()
session.window.close()
except NoSuchWindowException:
pass

View File

@ -12,7 +12,7 @@ def fixture_session(capabilities, session, create_window):
yield session
try:
session.close()
session.window.close()
except NoSuchWindowException:
pass

View File

@ -11,7 +11,7 @@ def test_no_browsing_context(session, create_window):
new_handle = create_window()
session.window_handle = new_handle
session.close()
session.window.close()
response = get_window_handles(session)
assert_success(response, window_handles)

View File

@ -17,7 +17,7 @@ def fixture_session(capabilities, session, create_window):
pass
try:
session.close()
session.window.close()
except NoSuchWindowException:
pass

View File

@ -230,7 +230,7 @@ def closed_window(session, create_window):
new_handle = create_window()
session.window_handle = new_handle
session.close()
session.window.close()
assert new_handle not in session.handles, "Unable to close window {}".format(new_handle)
yield new_handle

View File

@ -70,7 +70,7 @@ def cleanup_session(session):
for window in _windows(session, exclude=[current_window]):
session.window_handle = window
if len(session.handles) > 1:
session.close()
session.window.close()
session.window_handle = current_window