jmreidy / grunt-mocha-webdriver

Grunt task to run Mocha tests against a WebDriver source - either PhantomJS or Sauce Labs
MIT License
36 stars 17 forks source link

ECONNREFUSED on file upload #60

Closed binarykitchen closed 10 years ago

binarykitchen commented 10 years ago

When doing this:

browser.uploadFile(VIDEO_PATH + 'hamster-andele.wmv').nodeify(done);

I get this error

     Error: connect ECONNREFUSED
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19

I am running local PhantomJS tests here. All I want is to upload that video file. It exists and the above path is correct.

Any ideas why it is not working?

saadtazi commented 10 years ago

I didn't use it, but i based on a quick search, I thinkuploadFile should be called on an element (an input of type "file").

So browser.elementByX('...').uploadFile(...)

On May 8, 2014, at 22:50, Michael Heuberger notifications@github.com wrote:

When doing this:

browser.uploadFile(VIDEO_PATH + 'hamster-andele.wmv').nodeify(done); I get this error

 Error: connect ECONNREFUSED
at errnoException (net.js:904:11)
at Object.afterConnect [as oncomplete] (net.js:895:19

I am running local PhantomJS tests here. All I want is to upload that video file. It exists and the above path is correct.

Any ideas why it is not working?

— Reply to this email directly or view it on GitHub.

binarykitchen commented 10 years ago

I am afraid @saadtazi it does not work either. Is there a working example for a file upload?

saadtazi commented 10 years ago

No, I don't have any example. Some people are experiencing problem with file upload and phantom/ghostdriver.

Check those links:

Did you try with other browsers? It seems to be a bug/limitation in ghostdriver (or wd, but I doubt), not a bug in grunt-mocha-webdriver.

saadtazi commented 10 years ago

Maybe you can try to use sendKeys instead? https://github.com/admc/wd/issues/238

binarykitchen commented 10 years ago

@saadtazi No I didn't try with other browsers - It has to work with PhantomJS otherwise I can forget my whole project :/

I am really surprised that there are no working examples out there! Has anybody a working example??

saadtazi commented 10 years ago

check the test in this pull request: https://github.com/admc/wd/pull/122/files.

binarykitchen commented 10 years ago

thanks

hmmm, this line https://github.com/admc/wd/pull/122/files#diff-2986f79d93293ab0d493da37ba6f35f8R1919 confirms that it won't work on ghostdriver aka PhantomJS :(

Three questions @saadtazi

saadtazi commented 10 years ago

Yes, and from admc/wd#107, the author of ghostdriver mentionned that if it is not documented, it is not supported... And uploadFile is still not documented in jsonWire...

binarykitchen commented 10 years ago

Lots of "I don't know"s ... :(

Ok, for my local PhantomJS-based E2E tests I tried sendKeys() recently and still experience the same issues. Test still failing.

Here more information. In my code I output lots of debug info:

COMMAND > RESPONSE elementByName("file-select") {"ELEMENT":":wdc:1399954541928"}
COMMAND > CALL element.sendKeys("/home/michael.heuberger/binarykitchen/code/signdna/server/test/video/hamster-andele.wmv") 
HTTP > POST /session/:sessionID/file {"file":"UEsDBBQACAAIAPWBrUQAAAAAAAAAAAAAAAASAAAAaGFtc3Rlci1hbmRlbGUud2127LxlWJtbtzYaglMcWgguAYK7U1yCO4XiDsUpUNzd3d21UIq2RYpb8eJtcXcoL ...
...
[over 1000 lines like that]
...
/2cbOcmNnj7HecqwXG2ulY60E1B7QEkEpAwSpBOjZ7UXpgBfpV75n7Pzr6UDbnUepPun4NT1VW658dfUIQbVkdsR+teuky9TY9MgFtNmx9Hvb7z/+D54mg6H/6P9/AVBLBwjmwfjL684HAI0KCABQSwECFAAUAAgACAD1ga1E5sH4y+vOBwCNCggAEgAAAAAAAAAAAAAAAAAAAAAAaGFtc3Rlci1hbmRlbGUud212UEsFBgAAAAABAAEAQAAAACvPBwAAAA=="}
    1) upload file to server // IN RED
LOG > [INFO  - 2014-05-13T04:15:16.221Z] GhostDriver - Main - running on port 4444
[INFO  - 2014-05-13T04:15:16.246Z] Session [2fed4100-da55-11e3-8fb3-4d014ccbfe85] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34","webSecurityEnabled":true}
[INFO  - 2014-05-13T04:15:16.246Z] Session [2fed4100-da55-11e3-8fb3-4d014ccbfe85] - page.customHeaders:  - {}
[INFO  - 2014-05-13T04:15:16.246Z] Session [2fed4100-da55-11e3-8fb3-4d014ccbfe85] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.7","driverName":"ghostdriver","driverVersion":"1.1.0","platform":"linux-unknown-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2014-05-13T04:15:16.246Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 2fed4100-da55-11e3-8fb3-4d014ccbfe85

There is more but these are the relevant lines. 1) upload file to server is in RED and it's failing. And then a new session is started.

I think we need to add tests to make sure file uploads work locally and remotely both. In this module. This to ensure stability. Pointing to https://github.com/admc/wd doesn't help.

binarykitchen commented 10 years ago

While debugging I found out that the PhantomJS process wasn't running anymore, hence the ECONNREFUSED. Something inside the file upload must have caused the PhantomJS process to exit early.

binarykitchen commented 10 years ago

More info see https://github.com/admc/wd/issues/303

I can confirm, it is a WD issue. Sorry!