Skip to content

Commit

Permalink
Update window commands to use W3C End points
Browse files Browse the repository at this point in the history
When speaking to a W3C End point we should use the W3C Window endpoints
instead of the JSONWP ones.
  • Loading branch information
AutomatedTester committed Apr 4, 2017
1 parent 5f96eb0 commit 44ef2cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions py/selenium/webdriver/remote/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class Command(object):
SUBMIT_ELEMENT = "submitElement"
UPLOAD_FILE = "uploadFile"
GET_CURRENT_WINDOW_HANDLE = "getCurrentWindowHandle"
W3C_GET_CURRENT_WINDOW_HANDLE = "w3cGetCurrentWindowHandle"
GET_WINDOW_HANDLES = "getWindowHandles"
W3C_GET_WINDOW_HANDLES = "w3cGetWindowHandles"
GET_WINDOW_SIZE = "getWindowSize"
W3C_GET_WINDOW_SIZE = "w3cGetWindowSize"
W3C_GET_WINDOW_POSITION = "w3cGetWindowPosition"
Expand Down
4 changes: 4 additions & 0 deletions py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,12 @@ def __init__(self, remote_server_addr, keep_alive=False, resolve_ip=True):
Command.QUIT: ('DELETE', '/session/$sessionId'),
Command.GET_CURRENT_WINDOW_HANDLE:
('GET', '/session/$sessionId/window_handle'),
Command.W3C_GET_CURRENT_WINDOW_HANDLE:
('GET', '/session/$sessionId/window'),
Command.GET_WINDOW_HANDLES:
('GET', '/session/$sessionId/window_handles'),
Command.W3C_GET_WINDOW_HANDLES:
('GET', '/session/$sessionId/window/handles'),
Command.GET: ('POST', '/session/$sessionId/url'),
Command.GO_FORWARD: ('POST', '/session/$sessionId/forward'),
Command.GO_BACK: ('POST', '/session/$sessionId/back'),
Expand Down
10 changes: 8 additions & 2 deletions py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,10 @@ def current_window_handle(self):
:Usage:
driver.current_window_handle
"""
return self.execute(Command.GET_CURRENT_WINDOW_HANDLE)['value']
if self.w3c:
return self.execute(Command.W3C_GET_CURRENT_WINDOW_HANDLE)['value']
else:
return self.execute(Command.GET_CURRENT_WINDOW_HANDLE)['value']

@property
def window_handles(self):
Expand All @@ -563,7 +566,10 @@ def window_handles(self):
:Usage:
driver.window_handles
"""
return self.execute(Command.GET_WINDOW_HANDLES)['value']
if self.w3c:
return self.execute(Command.W3C_GET_WINDOW_HANDLES)['value']
else:
return self.execute(Command.GET_WINDOW_HANDLES)['value']

def maximize_window(self):
"""
Expand Down

0 comments on commit 44ef2cb

Please sign in to comment.