3

I build my project on Travis CI. I run tests the following way:

  1. Run Firefox with index.html parameter, which loads script that attempts to connect repeatedly to websocket server.
  2. Run simple websocket server that sends commands to Firefox.
  3. Script in Firefox reads these commands (they may contain some JavaScript code to test), executes JavaScript code.

This works when I run things locally. This also used to work on Travis a couple of weeks ago. However, things that worked for years, had broken unexpectedly. Firefox reports no errors, but node.js server receives no incoming connections for some timeout. I don't know the way to debug the problem. Script that runs in Firefox uses console.log extensively, however I can't retrieve these logs from Travis. Is there any way to get some information from Firefox that runs on CI server?

Note: I run Firefox 53. After things got broken, I tried to upgrade to recent version. Also, I used to run following commands before running Firefox:

export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sleep 10

And I tried to remove these lines and use headless more, however this didn't work.

Alexey Andreev
  • 1,980
  • 2
  • 17
  • 29

2 Answers2

0

Script that runs in Firefox uses console.log extensively, however I can't retrieve these logs from Travis. Is there any way to get some information from Firefox that runs on CI server?

Firefox 65+ supports a new devtools.console.stdout.content about:config preference, which you can set to true to make the Console output be dumped to stdout (and appear in Travis, I believe).

There doesn't seem to be a good solution for earlier versions: Selenium's driver.get_log() doesn't work in Firefox, and other solutions look unsatisfactory to me.

You seem to run index.html as a file:/// URL, in my opinion that's asking for trouble - I recommend spending time to set up a local https:// server, to save time debugging ever-increasing "security" restrictions the browsers add for non-https content.

If the above doesn't help, try reproducing this with a minimal testcase in a separate repo; if the problem persists, you can share that repo in another question.

Nickolay
  • 31,095
  • 13
  • 107
  • 185
  • "about:config preference" - how can I set this? I don't have access to Firefox GUI, it's CI server. – Alexey Andreev Aug 23 '19 at 08:17
  • Check out https://developer.mozilla.org/en-US/docs/Mozilla/Preferences/A_brief_guide_to_Mozilla_preferences – Nickolay Aug 23 '19 at 11:10
  • Ok, I gave you reward, but still could not make things work. The link to preferences documentaion you provided did not help. I assumes I know either location of firefox installation or profiles. However, looks like there's no way to create profile from command line, like in case of Chrome, which takes path to profile directory in command line and automatically creates profile at the given path. – Alexey Andreev Aug 28 '19 at 08:56
  • Firefox works the same way, I just tested: `rm -rf ./my-profile; mkdir ./my-profile && echo "user_pref('a.b.c', 123);" > ./my-profile/user.js && /Applications/Firefox.app/Contents/MacOS/firefox-bin -profile `pwd`/my-profile -no-remote` – Nickolay Aug 28 '19 at 15:02
  • (You have to know the location of the Firefox binary or have it in the PATH in order to run it, obviously.) // the above command was supposed to be `-profile \`pwd\`/my-profile`, i.e. the absolute path to the profile directory. – Nickolay Aug 28 '19 at 15:27
0

You can run vnc with xvfb and connect to it with vncviewer. Here you have some more details: https://www.alexkras.com/debugging-xvfb-server-with-vnc/

pawelbylina
  • 1,387
  • 10
  • 17