Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4786)

Unified Diff: chrome/test/chromedriver/client/chromedriver.py

Issue 2230053002: [chromedriver] Added option to make element references W3C compliant. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed presubmit errors. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/chromedriver/chrome_launcher.cc ('k') | chrome/test/chromedriver/commands.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/client/chromedriver.py
diff --git a/chrome/test/chromedriver/client/chromedriver.py b/chrome/test/chromedriver/client/chromedriver.py
index f211bb4589a95da7dca7a453928cb6abe6b007f2..f3d6880d94254819043fc4cbe16b28b78a1e461b 100644
--- a/chrome/test/chromedriver/client/chromedriver.py
+++ b/chrome/test/chromedriver/client/chromedriver.py
@@ -9,6 +9,8 @@ import command_executor
from command_executor import Command
from webelement import WebElement
+ELEMENT_KEY_W3C = "element-6066-11e4-a52e-4f735466cecf"
+ELEMENT_KEY = "ELEMENT"
class ChromeDriverException(Exception):
pass
@@ -208,6 +210,7 @@ class ChromeDriver(object):
self._session_id = response['sessionId']
self.capabilities = self._UnwrapValue(response['value'])
+
def _WrapValue(self, value):
"""Wrap value from client side for chromedriver side."""
if isinstance(value, dict):
@@ -216,18 +219,25 @@ class ChromeDriver(object):
converted[key] = self._WrapValue(val)
return converted
elif isinstance(value, WebElement):
- return {'ELEMENT': value._id}
+ if (self.w3c_compliant):
+ return {ELEMENT_KEY_W3C: value._id}
+ else:
+ return {ELEMENT_KEY: value._id}
elif isinstance(value, list):
return list(self._WrapValue(item) for item in value)
else:
return value
def _UnwrapValue(self, value):
- """Unwrap value from chromedriver side for client side."""
if isinstance(value, dict):
- if (len(value) == 1 and 'ELEMENT' in value
- and isinstance(value['ELEMENT'], basestring)):
- return WebElement(self, value['ELEMENT'])
+ if (self.w3c_compliant and len(value) == 1
+ and ELEMENT_KEY_W3C in value
+ and isinstance(
+ value[ELEMENT_KEY_W3C], basestring)):
+ return WebElement(self, value[ELEMENT_KEY_W3C])
+ elif (len(value) == 1 and ELEMENT_KEY in value
+ and isinstance(value[ELEMENT_KEY], basestring)):
+ return WebElement(self, value[ELEMENT_KEY])
else:
unwraped = {}
for key, val in value.items():
« no previous file with comments | « chrome/test/chromedriver/chrome_launcher.cc ('k') | chrome/test/chromedriver/commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698