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

NPE in RemoteWebDriver:249 at findElements(String, String) #3800

Closed
lukeis opened this issue Mar 3, 2016 · 22 comments
Closed

NPE in RemoteWebDriver:249 at findElements(String, String) #3800

lukeis opened this issue Mar 3, 2016 · 22 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 3800

Selenium 2.21.0, Java, RemoteWebDriver, line 249 -> NPE


What steps will reproduce the problem?

- Sometimes, when the browser is loading a page asyncly and the screen is still blank,
a try to find an element ends with NPE, the "allElements" variable seems to be null.

Is this specific enough, or should I try hard to pinpoint the condition on which it
happens?


Selenium version: 2.21.0
OS: Windows XP SP3
Browser: IE
Browser version: 8

Reported by PhotoSlanec on 2012-04-25 13:27:58

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

...okay, I take it back. It was not even an async load - it was a fairly regular repetitive
load (redirected once). Anyway, the driver.findElements(By) command obviously ran when
it was not expected to run (and I think we can't blame it).

Reported by PhotoSlanec on 2012-04-25 13:33:23

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Closed after the previous comment

Reported by barancev on 2012-05-02 19:21:39

  • Status changed: Invalid

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

And I just discovered a reproducable one!

Reported by PhotoSlanec on 2012-05-02 19:29:17

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Added a reproducible testcase.

With Selenium 2.21.0 and IE8 on Windows XP SP3, it fails every time with a NPE on a
stated line.

Works ok on FF11.

Reported by PhotoSlanec on 2012-05-02 19:35:06


- _Attachment: [NPE.html](https://storage.googleapis.com/google-code-attachments/selenium/issue-3800/comment-4/NPE.html)_ - _Attachment: [NPE.java](https://storage.googleapis.com/google-code-attachments/selenium/issue-3800/comment-4/NPE.java)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reopening

Reported by barancev on 2012-05-03 06:23:18

  • Status changed: New

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Same case happens using the grid.

Selenium server grid version: 2.21.0
Internet Explorer driver: IEDriverServer_x64_2.21.3
OS: Windows 7
Browser: IE
Browser version: 9

Stacktrace with more info:

org.openqa.selenium.WebDriverException: Build info: version: '2.2.1', revision: '16551',
time: '2012-04-11 21:42:35'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.4', java.version:
'1.6.0_31'
Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:175)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:128)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:459)
    at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:246)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementsByCssSelector(RemoteWebDriver.java:308)
    at org.openqa.selenium.By$ByCssSelector.findElements(By.java:417)
    at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:215)
Build info: version: '2.2.1', revision: '16551', time: '2012-04-11 21:42:35'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.4', java.version:
'1.6.0_31'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:108)
    ... 40 more
Caused by: java.lang.NullPointerException

Reported by almazzo on 2012-05-25 19:25:37

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I've got additional information about this NPE. Today a customer of mine shown me a
very similar stack trace, and here is the real NPE exception on the server side:

Caused by: java.lang.NullPointerException
 at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187)
 at com.google.common.collect.ImmutableMap.of(ImmutableMap.java:75)
 at org.openqa.selenium.remote.server.handler.FindElements$1.apply(FindElements.java:54)
 at org.openqa.selenium.remote.server.handler.FindElements$1.apply(FindElements.java:1)
 at com.google.common.collect.Iterators$8.next(Iterators.java:782)
 at com.google.common.collect.Sets.newLinkedHashSet(Sets.java:267)
 at org.openqa.selenium.remote.server.handler.FindElements.call(FindElements.java:51)
 at org.openqa.selenium.remote.server.handler.FindElements.call(FindElements.java:1)
 at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
 at java.util.concurrent.FutureTask.run(Unknown Source)

Reported by barancev on 2012-05-25 22:14:29

  • Labels added: Component-WebDriver, Browser-Firefox

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Uh, is there a way I could get the server stacktrace as well? Since I am able to reproduce
it every time (with the test case above, can anyone reproduce it, too?), I could try
to pinpoint the exact cause.

Reported by PhotoSlanec on 2012-05-26 10:01:29

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

And another reproducible one! In IE8 and Win XP SP3, this file causes the above described
NPE.

Reported by PhotoSlanec on 2012-06-12 10:23:45


- _Attachment: [TestyTest.java](https://storage.googleapis.com/google-code-attachments/selenium/issue-3800/comment-10/TestyTest.java)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Hi,

i reproduced this issue at Vista+IE9 configuration with test from comment #10.

The following lines are from ie driver log:

W 2012-07-25 07:36:18:954 Script.cpp(642) -2147024891 [Отказано в доступе.]: Unable
to execute code, call to IHTMLWindow2::execScript failed
W 2012-07-25 07:36:18:955 Script.cpp(220) Cannot create anonymous function
W 2012-07-25 07:36:18:955 ElementFinder.cpp(166) Unable to create criteria object for
mechanism name and criteriahaha

This situation is not correctly processed at FindElements command handler which leads
to sending null but not Json::null with success status code.
At another step, ias i understand, wd client during json to data (i think Response
bean) convert such null to reall Java null which leads to exception at some point.
:)

Patch with all (except one in JavaScriptAsync - i'm working on it right now) similar
situations in command handlers is attached.
Not sure that it can be applied directly but it covers all such places.



Reported by a.u.savchuk on 2012-07-25 04:34:02


- _Attachment: [issue_3800.patch](https://storage.googleapis.com/google-code-attachments/selenium/issue-3800/comment-11/issue_3800.patch)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by barancev on 2012-07-25 09:10:02

  • Labels added: Browser-IE
  • Labels removed: Browser-Firefox

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

NPE on different line number, but similar problem.

WebDriver: 2.25.0
IE 8
Windows 7

Attached reproducible test case: FindElementsTest.java

====================================================================================
Started InternetExplorerDriver server (32-bit)
2.25.2.0
Listening on port 34405
Aug 7, 2012 2:52:57 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Software
caused connection abort: recv failed
Aug 7, 2012 2:52:57 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
java.lang.NullPointerException
    at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:290)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementsByCssSelector(RemoteWebDriver.java:349)
    at org.openqa.selenium.By$ByCssSelector.findElements(By.java:416)
    at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:256)
    at com.bazaarvoice.automation.webrunner.keyword.TestCustomerImpl.twitterFramePass(TestCustomerImpl.java:32)

===============================================
Custom suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
====================================================================================

Reported by mgoodnow80 on 2012-08-07 20:01:05


- _Attachment: [FindElementsTest.java](https://storage.googleapis.com/google-code-attachments/selenium/issue-3800/comment-13/FindElementsTest.java)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I'm also getting a similair error. :-(
RemoteWebDriver.java line 290. Running through ruby and cucumbers selenium driver

unknown error (Selenium::WebDriver::Error::UnknownError)
[remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDriver.java):290:in
`findElements'
[remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDriver.java):357:in
`findElementsByXPath'
[remote server] org.openqa.selenium.By$ByXPath(By.java):338:in `findElements'
[remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDriver.java):256:in
`findElements'
[remote server] sun.reflect.GeneratedMethodAccessor31():-1:in `invoke'
[remote server] sun.reflect.DelegatingMethodAccessorImpl():-1:in `invoke'
[remote server] java.lang.reflect.Method():-1:in `invoke'
[remote server] org.openqa.selenium.support.events.EventFiringWebDriver$2(EventFiringWebDriver.java):101:in
`invoke'
[remote server] $Proxy1():-1:in `findElements'
[remote server] org.openqa.selenium.support.events.EventFiringWebDriver(EventFiringWebDriver.java):169:in
`findElements'
[remote server] org.openqa.selenium.remote.server.handler.FindElements(FindElements.java):48:in
`call'
[remote server] org.openqa.selenium.remote.server.handler.FindElements(FindElements.java):1:in
`call'
[remote server] java.util.concurrent.FutureTask$Sync():-1:in `innerRun'
[remote server] java.util.concurrent.FutureTask():-1:in `run'
[remote server] org.openqa.selenium.remote.server.DefaultSession$1(DefaultSession.java):150:in
`run'
[remote server] java.util.concurrent.ThreadPoolExecutor():-1:in `runWorker'
[remote server] java.util.concurrent.ThreadPoolExecutor$Worker():-1:in `run'
[remote server] java.lang.Thread():-1:in `run'

Reported by morgan.christiansson on 2012-08-22 18:21:01

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I've been able to reproduce the issue in http://code.google.com/p/selenium/issues/detail?id=3470
which is the same issue but using findElement() singular instead of findElements()
plural.

Reported by morgan.christiansson on 2012-09-03 14:39:47

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Anyone found a solution for this issue?

I have the same issue, but only sometimes.

Selenium version: 2.25.0
OS: Windows 7
Browser: IE
Browser version: 8

Reported by Stegmann.Ch on 2013-02-18 13:37:23

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Well, you know, you could update Selenium.

Reported by arran.huxtable on 2013-02-18 19:10:24

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

In which version is this issue fixed? The state of this defect is currently "new".

Reported by Stegmann.Ch on 2013-02-18 19:20:25

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

It's not fixed. We still have the issue in 2.29.0. IE 8-10. Haven't tried IE<8

Reported by craig.destigter@koordinates.com on 2013-02-18 20:02:08

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This issue was closed by revision 7a7da3104526.

Reported by james.h.evans.jr on 2013-02-18 21:23:44

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Thank you! I had workarounds for this at many places in my code! So good.

Reported by PhotoSlanec on 2013-02-18 21:27:37

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Be sure to take a close look at the change log for the revision. The change is a "best-faith"
effort to try to fix the issue. There may be corner cases that still aren't working.
Please open a new issue if that's the case.

Reported by james.h.evans.jr on 2013-02-18 21:34:24

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

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

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
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