Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It turns out the 'start-server' and 'stop-server' goals are for starting/stopping SeleniumRC servers. This is <em>NOT</em> what I wanted, as all my tests use the WebDriver API instead.</p> <p>Apparently the 'xvfb' goal in the pom DOES start an Xvfb session during the specified lifecycle phase - I guess I just didn't see it before. And in it's configuration, you specify where to write a props file detailing which display Xvfb is running on. In the Java code, this file can be read and the value passed to the FirefoxBinary used when creating the WebDriver.</p> <p>The relevant pom.xml bits are as follows:</p> <pre><code>&lt;properties&gt; &lt;displayProps&gt;target/selenium/display.properties&lt;/displayProps&gt; &lt;/properties&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;systemPropertyVariables&gt; &lt;display.props&gt;${displayProps}&lt;/display.props&gt; &lt;/systemPropertyVariables&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt; &lt;artifactId&gt;selenium-maven-plugin&lt;/artifactId&gt; &lt;version&gt;2.3&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;xvfb&lt;/id&gt; &lt;phase&gt;test-compile&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;xvfb&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;displayPropertiesFile&gt;${displayProps}&lt;/displayPropertiesFile&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; </code></pre> <p>This starts Xvfb on the first free display (:20 or above) and writes the value to the props file that I read and use later in my Java code.</p> <pre><code>String xvfbPropsFile = System.getProperty("display.props"); FirefoxBinary ffox = new FirefoxBinary(); ffox.setEnvironmentProperty("DISPLAY", /*read value from xvfbPropsFile*/); WebDriver driver = new FirefoxDriver(ffox); </code></pre> <p>Now the driver will be in control of the Firefox instance spun up in the appropriate display. Voila!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload