Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap Selenium in xvfb-run if available #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andrewnicols
Copy link
Contributor

By popular request

@mudrd8mz
Copy link
Contributor

mudrd8mz commented Sep 3, 2014

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
Copy link
Contributor Author

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

@mudrd8mz
Copy link
Contributor

mudrd8mz commented Sep 3, 2014

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
Copy link
Contributor Author

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
Copy link
Owner

FMCorz commented Nov 5, 2014

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:

  • add a config behat.useXvfb = false (with some comments)
  • have a config xvfb-run for the path to the binary (with a sensible default)
  • add this binary to mdk doctor --dependencies
  • not adding any argument to the behat command, most likely you will never want to run without xvfb if you want to use it on your system

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
Copy link
Contributor

mudrd8mz commented Nov 6, 2014

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
Copy link

nwp90 commented Jun 30, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants