зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1411281 - Associate web element identifier with webdriver.Element r=jgraham
MozReview-Commit-ID: Fqw3EJnJCsD --HG-- extra : rebase_source : c9437244567d54614e37f076642440d527ef75dd
This commit is contained in:
Родитель
7712fbf84c
Коммит
54e90b00f1
|
@ -8,8 +8,6 @@ from mozlog import get_default_logger
|
|||
|
||||
logger = get_default_logger()
|
||||
|
||||
element_key = "element-6066-11e4-a52e-4f735466cecf"
|
||||
|
||||
|
||||
def command(func):
|
||||
def inner(self, *args, **kwargs):
|
||||
|
@ -537,7 +535,7 @@ class Session(object):
|
|||
return self._element(data)
|
||||
|
||||
def _element(self, data):
|
||||
elem_id = data[element_key]
|
||||
elem_id = data[Element.identifier]
|
||||
assert elem_id
|
||||
if elem_id in self._element_cache:
|
||||
return self._element_cache[elem_id]
|
||||
|
@ -604,6 +602,14 @@ class Session(object):
|
|||
|
||||
|
||||
class Element(object):
|
||||
"""
|
||||
Representation of a web element.
|
||||
|
||||
A web element is an abstraction used to identify an element when
|
||||
it is transported via the protocol, between remote- and local ends.
|
||||
"""
|
||||
identifier = "element-6066-11e4-a52e-4f735466cecf"
|
||||
|
||||
def __init__(self, session, id):
|
||||
self.session = session
|
||||
self.id = id
|
||||
|
@ -615,7 +621,7 @@ class Element(object):
|
|||
return self.session.send_session_command(method, url, body)
|
||||
|
||||
def json(self):
|
||||
return {element_key: self.id}
|
||||
return {Element.identifier: self.id}
|
||||
|
||||
@command
|
||||
def find_element(self, strategy, selector):
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from webdriver.client import Element, element_key
|
||||
from webdriver.error import WebDriverException
|
||||
from webdriver import Element, WebDriverException
|
||||
|
||||
# WebDriver specification ID: dfn-error-response-data
|
||||
errors = {
|
||||
|
@ -105,10 +104,10 @@ def assert_same_element(session, a, b):
|
|||
"""Verify that two element references describe the same element."""
|
||||
assert isinstance(a, dict), "Actual value is not a dictionary"
|
||||
assert isinstance(b, dict), "Expected value is not a dictionary"
|
||||
assert element_key in a, "Actual value does not describe an element"
|
||||
assert element_key in b, "Expected value does not describe an element"
|
||||
assert Element.identifier in a, "Actual value does not describe an element"
|
||||
assert Element.identifier in b, "Expected value does not describe an element"
|
||||
|
||||
if a[element_key] == b[element_key]:
|
||||
if a[Element.identifier] == b[Element.identifier]:
|
||||
return
|
||||
|
||||
message = ("Expected element references to describe the same element, " +
|
||||
|
|
Загрузка…
Ссылка в новой задаче