Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated according to (not-so-new) property-based instantiation of the WebDriver in AbstractMagnoliaUITest
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

  1. Download In the VM, download Selenium Server (formerly the Selenium RC Server)
    Adjust AbstractMagnoliaUITest — locally only
  2. 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.
    • 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 a RemoteWebDriver
    • 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 the DesiredCapabilities
    • Code Block
      languagejava
      titleAbstractMagnoliaUITest.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
  3. ProfitAdjust the DEFAULT_DOMAIN constant as well, in AbstractMagnoliaIntegrationTest — locally only
  4. should be your machine's hostname or IP address as to be reachable from the guest
  5. e.g. http://mymachine.local:8299/

 

3. Fancy shell script + desktop launcher for the Selenium server

  1. 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
      languagebash
      titleselenium-server.sh
      #!/bin/bash
      gnome-terminal -e "java -jar selenium-server-standalone-2.42.2.jar"
  2. 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"

  3. The fancy icon
    • Select your script, right-click and go to the file Properties > Click the icon and select yours

...