6

I have Chrome working headless via a Selenium server by running xvfb bound to DISPLAY:10 and then running Selenium with a DISPLAY=:10 webdriver-manager start. So that's all fine.

I also have Chromedriver running directly from protractor by specifying directConnect: true in my protractor.conf.

What I'd like to do is a combination of the two, ie. run chromedriver directly (NO SELENIUM!), but somehow instruct it to run headless on DISPLAY :10.

In terms of topology, everything is run on the developer's PC. There are no servers involved. In a comment below, I mention a node server: this is being used to launch protractor instead of the more usual launching from the command line. I want protractor to be running on DISPLAY:0 so I can see its output, test failures etc. When it spawns chrome using chromedriver, I want chrome to be running on DISPLAY:10. My reason for doing this is that I want the chrome window to be bigger than my physical screen. See How can I screenshot the full height of a mobile form factor? for background.

Community
  • 1
  • 1
pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • Hi Andrew. It's not working because I don't know how to try to make it work. I can't find anywhere to configure the target DISPLAY for the launched chrome instance. – pinoyyid Feb 20 '16 at 13:17
  • java doesn't come into it. protractor is a node application. DISPLAY for the node application is DISPLAY=:0 because protractor is running on my X display. It's when protractor spawns the chromedriver that I want the chromedriver to connect to DISPLAY=:10 – pinoyyid Feb 20 '16 at 18:00
  • Sorry, deleted confusing comment. Obviously stuck in Java mode... – Andrew Regan Feb 20 '16 at 18:12
  • 1
    I'm having trouble working out the topology. So this is all on one server? xvfb on :10, `DISPLAY=:10`, Sel Server, chromedriver, and node/protractor - with your test calling Server / protractor remotely. Is that right? But you also say "DISPLAY for the node application is DISPLAY=:0", so is node/protractor and another chromedriver on a separate box? If this was all on one box, with DISPLAY=:10, then surely all graf would go through xvfb with no extra config. If not, surely you just need DISPLAY=otherBox:10 on the node box, assuming you don't want a separate xvfb there. – Andrew Regan Feb 21 '16 at 17:13
  • How are you launching your headless Chrome instance? – stuXnet Feb 21 '16 at 17:16

2 Answers2

2

I'm guessing the topology is like this:

  • Box A: xvfb, DISPLAY=:10, Selenium Server, chromedriver
  • Box B: DISPLAY=:0, node, protractor (directConnect: true), chromedriver
  • Box C: test runner.

I don't know how else it could be laid out, given that DISPLAY is an environment variable, not a parameter to be passed.

In which case, assuming you don't want a separate xvfb installed on Box B, and A is reachable (plus a decent connection) from B, the solution is simply to set:

DISPLAY=boxAHost:10

on Box B.

If A isn't reachable from B, it might be simplest to just duplicate the xvfb setup on both A and B, and have DISPLAY=:10 on both.

Community
  • 1
  • 1
Andrew Regan
  • 5,087
  • 6
  • 37
  • 73
  • see my updates to the question, there is only a single box. environment variables can be made specific to a a process, eg `DISPLAY=:10 protractor` – pinoyyid Feb 22 '16 at 10:36
  • Any chance you could share a link to info about being able to link to a process (maybe on your answer)? I couldn't find it documented anywhere. – Andrew Regan Feb 22 '16 at 16:24
  • sorry @Andrew, I don't understand your question "link to a process". If you can clarify I'll happily provide any info I have. Do you mean; invoke chromedriver directly, rather than via a Selenium server? If so it's documented https://github.com/angular/protractor/blob/master/docs/referenceConf.js see line 91'directConnect: false,' – pinoyyid Feb 23 '16 at 02:54
  • My bad, I meant linking DISPLAY to a process name. Hosts, screens etc. I know, but I couldn't find anything about adding a proc name and how that would get used. – Andrew Regan Feb 23 '16 at 07:50
2

I had a "Doh!!!" moment of zen and the whole thing is much easier that I thought it would be.

I had conflated the stdout of node/protractor (which I want on my screen) with the X display of chrome (which I want headless on DISPLAY:10). Of course they are totally different!!!!

Simply prefixing protractor with DISPLAY=:10 eg.

DISPLAY=:10 protractor /installation_test/conf-c-direct-noserver.js

or, in my case since I'm running a node server which in turn spawns protractor, ...

DISPLAY=:10 npm start

So protractor runs in my terminal and I can watch stdout, whereas the DISPLAY=:10 is inherited down through the call layers and is eventually seen and understood by Chrome.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115