Skip to content

Commit 1571e66

Browse files
committed
Revert "Taking XML namespaces into account when searching by XPath. Checked to work in Firefox. Chrome supports namespaces out of the box. Need to update IE and Safari drivers to use the updated atom and test them carefully."
This reverts commit 4f5f96d.
1 parent 4f5f96d commit 1571e66

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

java/client/test/org/openqa/selenium/ElementFindingTest.java

-10
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@
3232
import static org.junit.Assume.assumeFalse;
3333
import static org.openqa.selenium.testing.Ignore.Driver.ANDROID;
3434
import static org.openqa.selenium.testing.Ignore.Driver.CHROME;
35-
import static org.openqa.selenium.testing.Ignore.Driver.HTMLUNIT;
3635
import static org.openqa.selenium.testing.Ignore.Driver.IE;
3736
import static org.openqa.selenium.testing.Ignore.Driver.IPHONE;
3837
import static org.openqa.selenium.testing.Ignore.Driver.MARIONETTE;
3938
import static org.openqa.selenium.testing.Ignore.Driver.OPERA;
4039
import static org.openqa.selenium.testing.Ignore.Driver.OPERA_MOBILE;
4140
import static org.openqa.selenium.testing.Ignore.Driver.REMOTE;
42-
import static org.openqa.selenium.testing.Ignore.Driver.SAFARI;
4341
import static org.openqa.selenium.testing.TestUtilities.isOldIe;
4442

4543
import static org.hamcrest.Matchers.is;
@@ -401,14 +399,6 @@ public void testFindingALinkByXpathUsingContainsKeywordShouldWork() {
401399
assertThat(element.getText(), containsString("hello world"));
402400
}
403401

404-
@Ignore({ANDROID, HTMLUNIT, IE, IPHONE, OPERA, OPERA_MOBILE, MARIONETTE, SAFARI})
405-
@Test
406-
public void testShouldBeAbleToFindElementByXPathWithNamespace() {
407-
driver.get(pages.svgPage);
408-
WebElement element = driver.findElement(By.xpath("//svg:svg//svg:text"));
409-
assertThat(element.getText(), is("Test Chart"));
410-
}
411-
412402
// By.xpath negative
413403

414404
@Test(expected = NoSuchElementException.class)

javascript/atoms/locators/xpath.js

+3-25
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,9 @@ bot.locators.xpath.evaluate_ = function(node, path, resultType) {
9696
}
9797

9898
try {
99-
var reversedNamespaces = {};
100-
var allNodes = doc.getElementsByTagName("*");
101-
for (var i = 0; i < allNodes.length; ++i) {
102-
var node = allNodes[i];
103-
var ns = node.namespaceURI;
104-
if (!reversedNamespaces[ns]) {
105-
var prefix = node.lookupPrefix(ns);
106-
if (!prefix) {
107-
var m = ns.match('.*/(\\w+)/?$');
108-
if (m) {
109-
prefix = m[1];
110-
} else {
111-
prefix = 'xhtml';
112-
}
113-
}
114-
reversedNamespaces[ns] = prefix;
115-
}
116-
}
117-
var namespaces = {};
118-
for (var key in reversedNamespaces) {
119-
namespaces[reversedNamespaces[key]] = key;
120-
}
121-
var resolver = function(prefix) {
122-
return namespaces[prefix] || null;
123-
}
99+
var resolver = doc.createNSResolver ?
100+
doc.createNSResolver(doc.documentElement) :
101+
bot.locators.xpath.DEFAULT_RESOLVER_;
124102
if (goog.userAgent.IE && !goog.userAgent.isVersionOrHigher(7)) {
125103
// IE6, and only IE6, has an issue where calling a custom function
126104
// directly attached to the document object does not correctly propagate

0 commit comments

Comments
 (0)