Skip to content

Commit

Permalink
firefox: Fixing "null pointer exception" in xpath location strategy. …
Browse files Browse the repository at this point in the history
…Fixes issue SeleniumHQ#714
  • Loading branch information
barancev committed Jul 4, 2015
1 parent e7b9414 commit 788f40c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions java/client/test/org/openqa/selenium/ElementFindingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,15 @@ public void testShouldBeAbleToFindElementByXPathWithNamespace() {
assertThat(element.getText(), is("Test Chart"));
}

@Ignore({IE, MARIONETTE, SAFARI, CHROME})
@NotYetImplemented(HTMLUNIT)
@Test
public void testShouldBeAbleToFindElementByXPathInXmlDocument() {
driver.get(pages.simpleXmlDocument);
WebElement element = driver.findElement(By.xpath("//foo"));
assertThat(element.getText(), is("baz"));
}

// By.xpath negative

@Test(expected = NoSuchElementException.class)
Expand Down
2 changes: 1 addition & 1 deletion javascript/atoms/locators/xpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ bot.locators.xpath.evaluate_ = function(node, path, resultType) {
for (var i = 0; i < allNodes.length; ++i) {
var n = allNodes[i];
var ns = n.namespaceURI;
if (!reversedNamespaces[ns]) {
if (ns && !reversedNamespaces[ns]) {
var prefix = n.lookupPrefix(ns);
if (!prefix) {
var m = ns.match('.*/(\\w+)/?$');
Expand Down

0 comments on commit 788f40c

Please sign in to comment.