Bug 1204496: When searching by link text start from the startNode and not the rootNode; r=ato

--HG--
extra : commitid : B41EB2spDLA
extra : rebase_source : 19077dc84eefe0b11d862c04dc1f8bbc595cca82
This commit is contained in:
David Burns 2015-09-17 22:22:38 +01:00
parent 5f70fae987
commit cf7ee31873
3 changed files with 18 additions and 1 deletions

View File

@ -169,3 +169,11 @@ class TestElements(MarionetteTestCase):
self.assertIsNotNone(re.search(uuid_regex, el.id),
'UUID for the WebElement is not valid. ID is {}'\
.format(el.id))
def test_should_find_elements_by_link_text(self):
test_html = self.marionette.absolute_url("nestedElements.html")
self.marionette.navigate(test_html)
element = self.marionette.find_element(By.NAME, "div1")
children = element.find_elements(By.LINK_TEXT, "hello world")
self.assertEqual(len(children), 2)
self.assertEqual("link1", children[0].get_attribute("name"))
self.assertEqual("link2", children[1].get_attribute("name"))

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<a href="1.html">hello world</a>
<a href="1.html">hello world</a><a href="1.html">hello world</a>
<div name="div1">
<a href="2.html" name="link1">hello world</a>
<a href="2.html" name="link2">hello world</a>
</div>
<a href="1.html">hello world</a><a href="1.html">hello world</a><a href="1.html">hello world</a>

View File

@ -681,7 +681,7 @@ ElementManager.prototype = {
break;
case LINK_TEXT:
case PARTIAL_LINK_TEXT:
let allLinks = rootNode.getElementsByTagName('A');
let allLinks = startNode.getElementsByTagName('A');
for (let i = 0; i < allLinks.length; i++) {
let text = allLinks[i].text;
if (PARTIAL_LINK_TEXT == using) {