FMCorz / mdk

Moodle Development Kit. A collection of tools meant to make developers' lives easier.
GNU General Public License v3.0
85 stars 47 forks source link

Wrap Selenium in xvfb-run if available #93

Open andrewnicols opened 10 years ago

andrewnicols commented 10 years ago

By popular request

mudrd8mz commented 10 years ago

I would prefer a flag for the mdk behat to enable this. Something like -x, --xvfb. In certain situations, such as when demonstrating the Behat power to mortals at conferences etc, it is pretty impressive to display the browser window.

andrewnicols commented 10 years ago

How about a [-X|--no-xvfb] since xvfb is what you want most of the time?

mudrd8mz commented 10 years ago

Would work as well. The explicit "enable" variant could handle missing binary a bit better though - such as refusing to start with the explanation ("xvfb-run not found" or so)

andrewnicols commented 10 years ago

I don't think that there's any need to do that - not everyone needs xvfb. Only for certain window managers for example, and certain OSs.

As an example, I don't need it with Awesome on Debian, or with OS X.

I think it makes sense to use it if it's available by default, but not otherwise.

Thinking about it some more, it could be an [-x|--xvfb|-X|--no-xvfb] option on the CLI, with a default applied in config. If it is requested and not present, then we could error. if it's not requested, we could just not use it?

FMCorz commented 9 years ago

Hi Andrew,

I am happy to merge this, but I think that allowing both options is an overkill. So essentially I would be inclined to:

Hmm, now I'm thinking, if you run selenium with phantom, could xvfb be a problem?

To be honest, I have no idea what it is ;-).

Thanks! Fred

mudrd8mz commented 9 years ago

For the record, this is how I sorted out the focus stealing issue I had with Selenium in XFCE. I use tmux (but some other terminal multiplexer such as screen should work). Firstly, I start a new X display (startx -- :1) and inside it, I start a new tmux session. I run Behat, so it opens new Firefox and performs the tests. Then I switch back to the normal X display :0 and I attach to the existing tmux session where Behat is running. So from the :0 display, I can see and check the CLI output of the Behat tests executed in the :1 display. When needed, I just Ctrl+Alt+F8 to see the browser, too.

I was trying to give Xaphyr a chance but it gives me segfault for some reason and I'm too lazy to diagnose it now.

nwp90 commented 8 years ago

Fred - "most likely you will never want to run without xvfb if you want to use it on your system" - turns out not to be the case (I think), for me at least.

At the moment I run tests on a remote machine. I have Xvnc running and control where selenium's browser goes using the DISPLAY environment variable. I can minimise my VNC client window if I don't need to see what's going on, or I can bring it into the foreground if I do (or if I want to interact with it e.g. by pausing the scenario execution just before a problem).

I generally run all the tests without wanting to interact first, then re-run the problematic ones, sometimes with a pause added to allow me to test what extra steps might be needed to make it work.

I'm not familiar with xvfb, but my impression is that it won't allow this kind of interaction, so if I wanted to use it for the full runs I'd need the command-line option to be able to switch it to something else depending on what I wanted from each run.