Skip to content

Commit

Permalink
Add in support for W3C Get Active Element in Python. Fixes SeleniumHQ…
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Nov 18, 2016
1 parent 3475dd7 commit 183c51d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions py/selenium/webdriver/remote/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Command(object):
SWITCH_TO_FRAME = "switchToFrame"
SWITCH_TO_PARENT_FRAME = "switchToParentFrame"
GET_ACTIVE_ELEMENT = "getActiveElement"
W3C_GET_ACTIVE_ELEMENT = "w3cGetActiveElement"
GET_CURRENT_URL = "getCurrentUrl"
GET_PAGE_SOURCE = "getPageSource"
GET_TITLE = "getTitle"
Expand Down
1 change: 1 addition & 0 deletions py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def __init__(self, remote_server_addr, keep_alive=False, resolve_ip=True):
Command.ELEMENT_SCREENSHOT: ('GET', '/session/$sessionId/element/$id/screenshot'),
Command.FIND_ELEMENT: ('POST', '/session/$sessionId/element'),
Command.FIND_ELEMENTS: ('POST', '/session/$sessionId/elements'),
Command.W3C_GET_ACTIVE_ELEMENT: ('GET', '/session/$sessionId/element/active'),
Command.GET_ACTIVE_ELEMENT:
('POST', '/session/$sessionId/element/active'),
Command.FIND_CHILD_ELEMENT:
Expand Down
5 changes: 4 additions & 1 deletion py/selenium/webdriver/remote/switch_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def active_element(self):
:Usage:
element = driver.switch_to.active_element
"""
return self._driver.execute(Command.GET_ACTIVE_ELEMENT)['value']
if self._driver.w3c:
return self._driver.execute(Command.W3C_GET_ACTIVE_ELEMENT)
else:
return self._driver.execute(Command.GET_ACTIVE_ELEMENT)['value']

@property
def alert(self):
Expand Down

0 comments on commit 183c51d

Please sign in to comment.