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. Author's note: This page is a first draft, feel free to complete the missing parts. |
Outlook
- The Magnolia webapp runs on the host as usual
- with manual-tests profile
- e.g.
mvn clean install 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
...
2. Selenium server setup
- Download 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
AbstractMagnoliaUITest
— locally only - 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
- Basically replace the
FirefoxDriver
with aRemoteWebDriver
- pass on the URL of your selenium server
- default URL is something like
http://{your-hostname.local}:4444/wd/hub
- pass the
FirefoxProfile
along through theDesiredCapabilities
Code Block language java title AbstractMagnoliaUITest.java URL@BeforeClass public seleniumServerUrlstatic = null; tryvoid setUpOnce() { String vmHostName = "yourSystem.setProperty(SELENIUM_SERVER_HOST_NAME, "<your-vm-hostnamehostname>.local"); seleniumServerUrl = new URL(String.format(System.setProperty(DOMAIN_PROPERTY, "http://%s<your-hostname>.local:4444/wd8399/hub", vmHostName)); } catch (MalformedURLException e1) {} DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile); driver = new RemoteWebDriver(seleniumServerUrl, capabilities);
- Check out the attached patch file:
remote-webdriver.patch
- Launch a UI test from your IDE to validate the setup
- Adjust the
- ProfitAdjust the
DEFAULT_DOMAIN
constant as well, inAbstractMagnoliaIntegrationTest
— locally only - should be your machine's hostname or IP address as to be reachable from the guest e.g.
http://mymachine.local:8299/
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.
...
Overview
Content Tools