ajsharma
ajsharma

Reputation: 1188

Reverse X11 forwarding from Vagrant for Firefox

Is it possible for a Vagrant linux box to access the host machine's applications? More specifically is it possible for selenium to access my host's Firefox?

Currently, I'm using a Vagrant box of Ubuntu on top of OSX Mavericks to do my ruby-on-rails development, and use X11 and XQuartz to run the tests against the linux version of Firefox. However, I would love for the tests to run on the Ubuntu box but run against my OSX Firefox application.

Relevant Vagrantfile ssh settings at the moment:

config.ssh.forward_agent = true
config.ssh.forward_x11 = true

Thanks!

Upvotes: 1

Views: 1982

Answers (3)

scottalan
scottalan

Reputation: 1694

I was able to get this working by forwarding the Selenium port from my localhost to my Vagrant environment.

From my local machine: ssh -R 4444:localhost:4444 vagrant

The reference to 'vagrant' in the above command is a reference to my ~/.ssh/config file and the entry I have in it.

I then ran java -jar selenium-server-standalone-[VERSION].jar from my local machine and started tests in my Vagrant environment.

Upvotes: 2

Terry Wang
Terry Wang

Reputation: 13920

To display firefox within the virtual machine, you'll need to install Xorg Server (display server), it'll be easier if you just install a GNOME, KDE DE or LXDE/XFCE4/enlightenment WM.

Once installed, start a DM (lightdm, gdm, kdm, slim etc... up to you) to login to the desktop environment, open a terminal and ssh to your host (I haven't tried X11 forwarding from a Mac but for Linux/Unix it just works), do ssh -X user@HOST or ssh -Y user@HOST, once logged in, start firefox from command line firefox and it should be displayed within the guest VM.

Upvotes: 0

Grapsus
Grapsus

Reputation: 2762

From inside your vagrant box run: ssh -X host_ip, then run your tests.

Upvotes: 0

Related Questions