mantoni / mochify.js

☕️ TDD with Browserify, Mocha, Headless Chrome and WebDriver
MIT License
346 stars 57 forks source link

Selenium-based tests time out and crash #100

Closed obi1kenobi closed 9 years ago

obi1kenobi commented 9 years ago

I'm getting the following error message when running tests in Selenium + Chrome:

POST /wd/hub/session/0663c95a-64dd-4402-92b1-64cc84e1c9f9/execute_async

Unexpected HTTP status: 500 Internal Server Error

date: Tue, 21 Jul 2015 00:48:14 GMT
server: Jetty/5.1.x (Windows 7/6.1 amd64 java/1.8.0_51
expires: Thu, 01 Jan 1970 00:00:00 GMT
cache-control: no-cache
content-length: 628066
content-type: application/json; charset=utf-8

Response Status Code: 28
Response Message:
    asynchronous script timeout: result was not received in 0 seconds
      (Session info: chrome=44.0.2403.89)
      (Driver info: chromedriver=2.16.333243 (0bfa1d3575fc1044244f21ddb82bf87094
4ef961),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide
 any stacktrace information)
    Command duration or timeout: 6 milliseconds
    Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:
47'
    System info: host: 'dragon', ip: '18.101.24.235', os.name: 'Windows 7', os.a
rch: 'amd64', os.version: '6.1', java.version: '1.8.0_51'
    Driver info: org.openqa.selenium.chrome.ChromeDriver
    Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulati
onEnabled=false, chrome={userDataDir=C:\Users\predrag\AppData\Local\Temp\scoped_
dir42660_811}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true
, hasTouchScreen=false, version=44.0.2403.89, platform=XP, browserConnectionEnab
led=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true,
webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnab
led=true, cssSelectorsEnabled=true}]
    Session ID: b1b980811d7ac383f3899804c225b86f

Error: Unexpected HTTP status: 500 Internal Server Error

All tests pass when run individually -- the error seems to be related to the amount of time spent running the tests. Thus, running a few of the slowest tests together will also cause the error. Here is my setup: https://github.com/obi1kenobi/jester/tree/refactor

I'm very new to Selenium and Browserify, but changing the timeout from 0 to 10000 in this file of mochify fixes the problem and makes all tests pass.

Thoughts? Am I just using mochify wrong or is this a bug?

mantoni commented 9 years ago

Thanks for reporting. I see this every now and then as well. Setting the timeout to 0 causes min-wd to not set a timeout at all. This was basically an optimization to avoid extra HTTP requests. If this override is removed, it will default to 10000 in min-wd, so this is what I'm going to do now.

mantoni commented 9 years ago

Released in 2.10.1.

obi1kenobi commented 9 years ago

Thanks for acting on this so quickly. I have a couple of final questions -- if the timeout defaults to 10000 and my tests require more than that to finish, won't the same problem happen again? If so, would it be reasonable to control this via a new config option on mochify, similarly to the Mocha timeout option?

mantoni commented 9 years ago

Yes. You can configure the timeout in the .min-wd file or in your package.json: https://github.com/mantoni/min-webdriver#timeouts

obi1kenobi commented 9 years ago

Makes sense. I originally tried doing that, but I guess the timeout = 0 line in mochify may have overridden it. Thanks again!