Closed nishp1 closed 11 years ago
What do you mean with "first try always fails" ? Does it mean, first attempt to start+capture firefox fails ?
FF3.6 is pretty ancient, so there might be some different flags etc...
Right, on Windows 7 first attempt to start and capture fails. On second try, it fails to close the browser after running tests if singleRun is set to true.
On Mac OS, start and capture seem to work fine, but the firefox can't be closed. Hacking at it more, I found that, firefox 3.6 seems to fork off a different process. Testacular tries to close a process with pid of for example 6501 and pid of firefox running is 6502. So, the kill doesn't work. Interestingly, If I use -P instead of -profile, firefox doesn't fork and uses to the same pid and closing works fine.
Using testacular@canary... I get following error when launching Firefox 3.6:
DEBUG [launcher]: C:\Program Files (x86)\Mozilla Firefox\firefox.exe http://localhost:8899/?id=96925580 -profile C:\cygwin\tmp\testacular-96925580 -no-remote
ERROR [testacular]: { [Error: EPERM, open 'C:\cygwin\tmp\testacular-96925580\prefs.js']
errno: 50,
code: 'EPERM',
path: 'C:\\cygwin\\tmp\\testacular-96925580\\prefs.js' }
This can be fixed by using writeFile instead of createWriteStream in launcher/Firefox.js. I will create a pull-request for this in a bit. After making this change, here is the behavior I see in 0.4.0 and 0.5.8 and log:
1) First start and capture fail. 2) On second try, firefox opens a window that warns, "Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.", and then it opens Firefox, runs tests and closes the warning window.
My guess is that since the warning window comes up first, testacular captures it instead of the actual browsers instance. Do you know of any workarounds to this?
Log:
[2013-01-17 10:49:38.558] [DEBUG] config - autoWatch set to false, because of singleRun
INFO [testacular]: Testacular server started at http://localhost:8899/
INFO [launcher]: Starting browser Firefox
DEBUG [launcher]: Creating temp dir at C:\cygwin\tmp\testacular-71066907
DEBUG [watcher]: Resolved files:
C:/Users/npatel/AppData/Roaming/npm/node_modules/testacular/adapter/lib/mocha.js
C:/Users/npatel/AppData/Roaming/npm/node_modules/testacular/adapter/mocha.js
C:/Development/plugin/target/js/expect.js
C:/Development/plugin/target/js/sinon.js
C:/Development/plugin/target/js/require.js
C:/Development/plugin/target/js/jquery.js
C:/Development/plugin/src/main/webapp/js/plugin.js
C:/Development/plugin/src/test/js/PluginSpec.js
DEBUG [launcher]: C:\Program Files (x86)\Mozilla Firefox\firefox.exe -new-window http://localhost:8899/?id=71066907 -profile C:\cygwin\tmp\testacular-71066907 -no-remote
INFO [launcher]: Process id 4832
DEBUG [launcher]: Process Firefox exitted with code 0
DEBUG [launcher]: Cleaning temp dir C:\cygwin\tmp\testacular-71066907
INFO [launcher]: Trying to start Firefox again.
DEBUG [launcher]: Creating temp dir at C:\cygwin\tmp\testacular-71066907
DEBUG [launcher]: C:\Program Files (x86)\Mozilla Firefox\firefox.exe -new-window http://localhost:8899/?id=71066907 -profile C:\cygwin\tmp\testacular-71066907 -no-remote
INFO [launcher]: Process id 4460
DEBUG [web server]: serving: C:/Users/npatel/AppData/Roaming/npm/node_modules/testacular/static/client.html
DEBUG [web server]: serving: C:/Users/npatel/AppData/Roaming/npm/node_modules/testacular/static/testacular.js
DEBUG [testacular]: New browser has connected on socket SeB9-oPq0mGr-8OvM4SM
INFO [Firefox 3.6 (Windows)]: Connected on socket id SeB9-oPq0mGr-8OvM4SM
DEBUG [testacular]: All browsers are ready, executing
DEBUG [web server]: serving: C:/Users/npatel/AppData/Roaming/npm/node_modules/testacular/static/context.html
DEBUG [web server]: serving: C:/Users/npatel/AppData/Roaming/npm/node_modules/testacular/adapter/lib/mocha.js
DEBUG [web server]: serving: C:/Users/npatel/AppData/Roaming/npm/node_modules/testacular/adapter/mocha.js
DEBUG [web server]: serving: C:/Development/plugin/src/main/webapp/js/plugin.js
DEBUG [web server]: serving: C:/Development/plugin/src/test/js/PluginSpec.js
DEBUG [web server]: serving: C:/Development/plugin/target/js/expect.js
DEBUG [web server]: serving: C:/Development/plugin/target/js/sinon.js
DEBUG [web server]: serving: C:/Development/plugin/target/js/require.js
DEBUG [web server]: serving: C:/Development/plugin/target/js/jquery.js
Firefox 3.6 (Windows): Executed 14 of 14 (PASSED) (1.405 secs / NaN secs)
DEBUG [launcher]: Disconnecting all browsers
DEBUG [launcher]: Killing Firefox 4460
DEBUG [reporter]: JUnit results written to "C:/Development/plugin/target/surefire-reports/test-results.xml".
DEBUG [launcher]: Process Firefox exitted with code 0
DEBUG [launcher]: Cleaning temp dir C:\cygwin\tmp\testacular-71066907
The EPERM error is "you don't have permissions". I would be very surprised if using fs.writeFile() instead of createWriteStream would solve this issue. Testacular needs a temp directory (it checks bunch of env variables, eg. TMP). Change your permissions in C:\cygwin\tmp.
Note, that write to stream is synchronous and you changing it to fs.readFile is asynchronous, so I guess you are starting FF before actually writing the profile. That's why you getting this "FF already running" issue (because it's probably using the default profile).
Anyway, feel free to submit a pull request with change to fs.writeFile
, I'd merge it. (The reason it uses createWritableStream was just my laziness anyway)
Regards -profile
vs. -P
, the reason Testacular uses -profile
is that it accepts full path to profile folder, rather than name of the profile, so I don't think we should change this to -P
. (it used to be like that). FF3.5 is really old and I prefer to have it working on latest FF. So if you wanna change that, you might create a separate FF launcher (once https://github.com/vojtajina/testacular/tree/using-di gets merged, it should be super simple to write custom browser launcher plugin).
Using testacular 0.4.0...When running tests against Firefox 3.6, first try always fails. And on the next try, it doesn't close the browsers instance. Has anyone else seen this issue?