Selenium

I was watching Harry Percival's video about test-driven web development[1] the other day. I wonder if there is a way to use Selenium within vagrant. Is it possible to do so without installing X and Firefox, using the browser on the host machine?

I found a project[2] but I don't know if it needs to install X, and how is it possible to combine it with GSWD VM (It uses a different box and the structure looks very different).

Could you point me in the right direction?

[1] http://pyvideo.org/video/1657/ [2] https://github.com/mhenwood/django-selenium-vagrant/

Sorry You must be a logged in, registered user to answer a question.

Answers

Try the headless mode with Firefox WebDriver:

http://www.seleniumtests.com/2012/04/headless-tests-with-firefox-webdriver.html

Here you'll find an example how to use it in a more pythonic way with PyVirtualDisplay

http://stackoverflow.com/a/8910326

I know that the guest can't modify the host. My question is, couldn't you run the Selenium tests from the host? You'd have to make a host-local VM, but the Selenium tests would then have access to your local Firefox, which can hit 127.0.0.1:8888, right?

I use 64-bit windows, so installing packages which are not pure-Python is hard or even impossible. Sometimes I can't find the right binary, sometimes I can't install the binary inside the virtual environment (I had to let my venv access to global site-packages), sometimes the version is outdated, etc. The only solution there seems to be is installing a complete Linux distro. But if I have to switch between OSes just to run tests, I probably wouldn't run them as often as needed. Anyway, thanks for your advice. I see what I can do.
hoorzad on

Honestly, I can't. I haven't used Selenium beyond some minor playing. I don't see, though, why you wouldn't be able to run the Selenium tests on your host machine using your local Firefox.

Because virtual machines are sandboxed by design, so they can't modify state on the host machine. In this example, Selenium could not simply call the host machine Firefox installation. I can forget about VM and do everything on the host, but installing PIL(or Pillow) and Pycrypto on windows is far from comfortable, and it violates the principle of keeping test and production environment close.
hoorzad on