Page History
Info |
---|
UI tests typically require browser/machine focus (especially when entering text in input fields). To avoid being stuck while UI tests proceed, it's handy to run them — the Selenium part — inside a VM. |
toc
Outlook
- The Magnolia webapp runs on the host as usual
- with manual-tests profile
- e.g.
mvn clean verify -P jetty6-standalone,manual-tests
- free hint #1: run this build from another location on your machine than the one you typically work at
- free hint #2: run it in offline mode (
mvn -o ...
) if you just installed one of the modules you want to put under test
...
- Test execution is done from the IDE, i.e. also on the host
Instructions
1. VM Setup
- Setup your VM and install Ubuntu for example
- mount iso image in optical drive
- In VirtualBox preferences > Network > Host-only Networks, click the add icon
- creates a new virtual network interface e.g.
vboxnet0
- creates a new virtual network interface e.g.
- In VM Settings > Network
- 1st slot: select "Host-only Adapter", then choose the one you just created — that
vboxnet0
- 2nd slot: select NAT as is usually the default (to access the interwebs through the host)
- 1st slot: select "Host-only Adapter", then choose the one you just created — that
- Install guest additions
- When VirtualBox VM is running
- Devices > Insert Guest Additions CD image...
2. Selenium server setup
- In the VM, download Selenium Server (formerly the Selenium RC Server)
- http://docs.seleniumhq.org/download/
- should be something like
selenium-server-standalone-2.42.2.jar
- and then run it, e.g.
java -jar selenium-server-standalone-2.42.2.jar
- On your host, adjust
AbstractMagnoliaUITest
(keep it local)- Adjust the
SELENIUM_SERVER_HOST_NAME
system property to your VM's host-name- so that UI tests launched from your IDE know where to point selenium's
RemoteWebDriver
to.
- so that UI tests launched from your IDE know where to point selenium's
- Adjust the
DOMAIN_PROPERTY
system property to your host machine's host-name- so that your VM's Firefox can access your running instance on your host machine.
- mind that the port number may be different, depending on what branch/edition your bundle is currently running
Code Block language java title AbstractMagnoliaUITest.java @BeforeClass public static void setUpOnce() { System.setProperty(SELENIUM_SERVER_HOST_NAME, "<your-vm-hostname>.local"); System.setProperty(DOMAIN_PROPERTY, "http://<your-hostname>.local:8399/"); }
- Launch a UI test from your IDE to validate the setup
- Adjust the
- Profit
3. Fancy shell script + desktop launcher for the Selenium server
- Create a new script, e.g.
selenium-server
on the desktop as follows- (provided your selenium server jar is on the desktop too)
Code Block language bash title selenium-server.sh #!/bin/bash gnome-terminal -e "java -jar selenium-server-standalone-2.42.2.jar"
- Make it executable
chmod +x your-script
- Go to Nautilus (eq. Finder) preferences
- Edit > Preferences, "Behavior" tab
- Tick "Run executable text files when they are opened"
- The fancy icon
- Download it http://www.seleniumhq.org/images/selenium-logo.png and save it locally to e.g.
/home/{user}/.icons/
- Select your script, right-click and go to the file Properties > Click the icon and select yours
- Download it http://www.seleniumhq.org/images/selenium-logo.png and save it locally to e.g.
Double-click your script and you're good to go!
...
...
- just ping
- try to reach jetty-container (which runs in mac) with firefox which runs on the Linux VM
...
Overview
Content Tools