Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Intermittent XPath finding failure on Firefox #2099

Closed
lukeis opened this issue Mar 2, 2016 · 25 comments
Closed

Intermittent XPath finding failure on Firefox #2099

lukeis opened this issue Mar 2, 2016 · 25 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 2099

This has been reported on the mailing lists and occasionally manifests itself in our
test suite:
ElementAttributeTest.testShouldReturnNullWhenGettingTheValueOfAnAttribute ThatIsNotListed
performs a page load, then finding the body using XPath.

Occasionally, this call to findElement will fail with the following error:
Component returned failure code:
0x80070057 (NS_ERROR_ILLEGAL_VALUE)
[nsIDOMXPathEvaluator.createNSResolver]

This will be displayed in Firefox's error console when that happens:

nsCommandProcessor.js:314 - Exception caught by driver: findElement([object Object])
[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE)
[nsIDOMXPathEvaluator.createNSResolver]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"
 location: "JS frame :: resource://fxdriver/modules/atoms.js :: <TOP_LEVEL> :: line
2354"  data: no]

I suspect it's a timing issue, since the issue didn't manifest itself if there was
a delay between get() returning and findElement being called.

Reported by eran.mes on 2011-07-20 16:15:55

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm seeing this as well. I have some code asserting that a given text is present for
a "By" locator. Before I attempt to retrieve the text, i use a "wait.until" block,
just to make sure.

As the OP, I'm also seeing this with By.xpath expressions only and the error is thrown
in the "findElement" part of the ExpectedCondition.

I think I've seen this pretty consistenly on a test for a given page title using a
By.xpath("//head/title") locator on a page, that is generated really fast.

Reported by soelvfinne on 2011-07-26 08:05:17

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm also hitting this issue on Firefox5/Linux for very simple XPath statements such
as 

//*[@class='access-denied']

id("modalframe-container")

Reported by lists%thefoxhome.net@gtempaccount.com on 2011-07-26 17:58:57

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

After googling a little more for my issue, i realize it may actually be an error related
to using the redirect-after-post pattern/a race between get() and findElement()

Reported by soelvfinne on 2011-07-26 22:22:26

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

And I am using capybara, using this:

      should "only see the 'comment' action button" do
        assert has_selector?('#comment_button')
        assert has_selector?('#i_want_this_too_button')
        assert has_selector?('#make_offer_button')
      end

      should "see links to view offers" do
        assert has_selector?('.view_offer')
      end

and I get those errors every other time I run the tests..  It's proving to be very
frustrating!

Reported by patrick99e99 on 2011-07-27 23:20:55

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

FYI: This post (http://carol-nichols.com/2011/07/seleniumwebdrivererrorunhandlederror-ns_error_illegal_value/)
mentions a workaround if you're using Capybara.

Reported by geertgerritsen on 2011-07-28 09:01:24

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by eran.mes on 2011-08-02 09:58:36

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 2287 has been merged into this issue.

Reported by jari.bakken on 2011-08-23 23:11:49

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Most frameworks using WebDriver as a building block (Capybara, watir-webdriver) rely
heavily on XPath, so would be good to have this fixed by (at least) 2.6. 

Reported by jari.bakken on 2011-08-23 23:54:11

  • Labels added: BuildingBlock, Component-WebDriver, Browser-Firefox

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

We're seeing the same problem when running capybara and selenium-webdriver and any kind
of parallel testing tool (parallel_test, specjour) even though it runs perfectly when
running it on a single core.

Reported by khelal@monaqasat.com on 2011-09-05 18:20:31

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I've managed to reproduced it somewhat consistently, by running the native test suite
on Linux with Firefox 6 (on Gnome, *not* xvfb / xvnc). The last test before the failing
one is testShouldNotHangIfDocumentOpenCallIsNeverFollowedByDocumentCloseCall:

Testcase: testShouldNotHangIfDocumentOpenCallIsNeverFollowedByDocumentCloseCall took
0.035 sec
Testcase: testShouldReturnNullWhenGettingTheValueOfAnAttributeThatIsNotListed took
0.031 sec
        Caused an ERROR
The given selector /html is either invalid or does not result in a WebElement. The
following error occurred:
[InvalidSelectorError] Unable to locate an element with the xpath expression /html
because of the following error:
[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE)
[nsIDOMXPathEvaluator.createNSResolver]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"
 location: "JS frame :
: resource://fxdriver/modules/atoms.js :: <TOP_LEVEL> :: line 2382"  data: no]; duration
or timeout: 22 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html
Build info: version: '2.7.0', revision: '13884', time: '2011-09-21 13:55:08'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '2.6.38.8-gg621', java.version:
'1.6.0-google-v4'
Driver info: driver.version: RemoteWebDriver
org.openqa.selenium.InvalidSelectorException: The given selector /html is either invalid
or does not result in a WebElement. The following error occurred:
[InvalidSelectorError] Unable to locate an element with the xpath expression /html
because of the following error:
[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE)
[nsIDOMXPathEvaluator.createNSResolver]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"
 location: "JS frame :: resource://fxdriver/modules/atoms.js :: <TOP_LEVEL> :: line
2382"  data: no]; duration or timeout: 22 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html
Build info: version: '2.7.0', revision: '13884', time: '2011-09-21 13:55:08'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '2.6.38.8-gg621', java.version:
'1.6.0-google-v4'
Driver info: driver.version: RemoteWebDriver

Reported by eran.mes on 2011-09-21 15:45:23

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

just want to chime in - we're seeing the same thing: seems to be reasonably consistent
when we pop a modal overlay on page load and try to confirm the existence of some text
in the overlay:


 Failure/Error: page.should have_content "Success! Your item is now listed."
     Selenium::WebDriver::Error::InvalidSelectorError:
       The given selector "./descendant-or-self::*[contains(normalize-space(.), 'Success!
Your item is now listed.')] is either invalid or does not resultin a Webelement. The
following error occurred:
       [InvalidSelectorError] Unable to locate elements with the xpath expression ./descendant-or-self::*[contains(normalize-space(.),
'Success! Your item is now listed.')] because of the following error:
       [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE)
[nsIDOMXPathEvaluator.createNSResolver]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"
 location: "JS frame :: resource://fxdriver/modules/atoms.js :: <TOP_LEVEL> :: line
2360"  data: no]
     # [remote server] file:///var/folders/ll/0csh8smd025d9mgh2nf842400000gn/T/webdriver-profile20110923-3328-9h1oht/extensions/fxdriver@googlecode.com/components/driver-component.js
-> file:///var/folders/ll/0csh8smd025d9mgh2nf842400000gn/T/webdriver-profile20110923-3328-9h1oht/extensions/fxdriver@googlecode.com/components/firefoxDriver.js:466:in
`unknown'
     # [remote server] file:///var/folders/ll/0csh8smd025d9mgh2nf842400000gn/T/webdriver-profile20110923-3328-9h1oht/extensions/fxdriver@googlecode.com/components/driver-component.js
-> file:///var/folders/ll/0csh8smd025d9mgh2nf842400000gn/T/webdriver-profile20110923-3328-9h1oht/extensions/fxdriver@googlecode.com/components/firefoxDriver.js:507:in
`unknown'
     # [remote server] file:///var/folders/ll/0csh8smd025d9mgh2nf842400000gn/T/webdriver-profile20110923-3328-9h1oht/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js:306:in
`unknown'
     # [remote server] file:///var/folders/ll/0csh8smd025d9mgh2nf842400000gn/T/webdriver-profile20110923-3328-9h1oht/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js:320:in
`unknown'
     # [remote server] file:///var/folders/ll/0csh8smd025d9mgh2nf842400000gn/T/webdriver-profile20110923-3328-9h1oht/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js:197:in
`unknown'
     # (eval):2:in `has_content?'

Reported by travis.vachon on 2011-09-23 14:49:35

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

See also revision 13403

Reported by dawagner on 2011-09-23 16:27:04

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I can trigger this error fairly consistently by running a Selenium wait_until on a page
with a meta Refresh=1 header, meaning it reloads every second.  If the wait_until check
(every 0.05s) coincides with a page reload, it goes boom.

Reported by jpatokal on 2011-09-26 06:37:38

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Could you post a code example?

Reported by ruelloehr on 2011-09-26 19:14:13

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Is this issue related to a specific version?

Reported by guilherme.garnier on 2011-10-03 19:55:57

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

The meta refresh trick will trigger issue 1438 for me, but not this one. I've added
it as an example there.

Reported by jari.bakken on 2011-10-03 20:03:12

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I get this same error about 35% of the time on certain tests runs.  It's not 100% repeatable,
and will only fail sometimes.

The location appears to immediately after raising, and then confirming, a modal dialog.
  Then shortly afterwards, when looking for this relatively straightforward xpath:
 "./descendant-or-self::*[contains(normalize-space(.), 'Song 0')]",  I get this exception:

[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE)
[nsIDOMXPathEvaluator.createNSResolver]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"
 location: "JS frame :: resource://fxdriver/modules/atoms.js :: <TOP_LEVEL> :: line
2361"  data: no]

I see this error in a number of different projects.   I've observed it in both version
2.5 and 2.7.

I can try to produce a minimum reproduction case, but at the moment I'm seeing this
in Rails applications using capybara and ruby selenium-webdriver.  It tends to happen
more when large numbers of tests are being run at once, so I'm not confident a minimum
case would actually reproduce it.   Timing issue, perhaps?

The capybara code that triggers it in one project looks like this (we're using an rspec
plugin that maintains state between examples in sequence):

  it "when I click destroy " do
    within "#track_#{@track.id}" do
      click_link "Destroy"
    end
    # accept the confirmation dialog
    alert = page.driver.browser.switch_to.alert
    alert.accept
  end

  it "should no longer show the track in the list" do
    page.should_not have_content(@track.name)
  end




Reported by evan@lrdesign.com on 2011-10-05 00:26:30

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm also having this issue with Ruby 1.8.7, Capybara and selenium-webdriver. I've tested
with versions 2.6.0 and 2.7.0, and both have this problem.

The error appears for me intermittently on the following lines:

page.should have_content(text)
fill_in(field, :with => value)
click_link(link)
choose(field)

Reported by guilherme.garnier on 2011-10-06 12:47:40

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Is this issue fixed? I'm facing the same problem... 

Reported by TheOutlander on 2011-10-18 20:52:55

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

FYI,

here's another version of a fix for Capybara:

https://gist.github.com/1137135

Reported by wdchew on 2011-10-18 23:20:08

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

This issue was closed by revision r14381.

Reported by simon.m.stewart on 2011-10-26 01:09:06

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Which version of selenium-webdriver ruby gem will incorporate this fix? Is there any
page with release notes for each version of selenium products?

Reported by vitaliy.grigoruk on 2011-10-26 16:02:10

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

This will be in the 2.10 gem which should go out this week. You can find the Ruby change
log here:

http://code.google.com/p/selenium/source/browse/trunk/rb/CHANGES

Reported by jari.bakken on 2011-10-26 17:19:10

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by jari.bakken on 2015-02-26 23:01:20

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by luke.semerau on 2015-09-17 18:13:17

  • Labels added: Restrict-AddIssueComment-Commit

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant