Configure Selenium

The Selenium configurations are defined in the twist.properties file. This file can be accessed by searching for it using CTRL+SHIFT+R (or CMD+SHIFT+R on mac) or by navigating to the project's source directory in the Package Explorer View.

Selenium options on Twist properties file

The browser type and other configuration options can be defined in the twist.properties file.

The following Selenium options are supported in Twist:
  • -port <nnnn>: the port number the Selenium server should use (default 4444).
  • -timeout <nnnn>: number of seconds before we should give up (integer).
  • -multiWindow: puts you into a mode where the web site under test executes in a separate window. Selenium supports frames in this mode.
  • -forcedBrowserMode <browser>: sets the browser mode (e.g. "*iexplore" for all sessions, no matter what is passed to getNewBrowserSession().
  • -userExtensions <file> indicates a JavaScript file that will be loaded into Selenium.
  • -browserSessionReuse: stops re-initialization and spawning of the browser between tests.
  • -avoidProxy: By default, Selenium proxies every browser request. Set this flag to make the browser use Selenium proxy only for URLs containing '/selenium-server'
  • -firefoxProfileTemplate <dir>: normally, a fresh Firefox profile is generated for each launch. You can specify the Firefox profile directory instead.
  • -proxyInjectionMode: puts you into proxy injection mode, a mode where the Selenium server acts as a proxy server for all content going to the application under test. Under this mode, multiple domains can be visited, and the following additional flags are supported:
    • -dontInjectRegex <regex>: regular expression of URLs used to bypass proxy injection mode.
    • -userJsInjection <file>: specifies a JavaScript file which will be injected into all pages.
    • -userContentTransformation <regex> <replacement>: a regular expression which is matched against all test HTML content; the second is a string which will replace matches.
    These flags can be used any number of times. An example of how this could be useful: if you add "-userContentTransformation https http" then all "https" strings in the HTML of the application under test will be changed to "http".
Addtional properties
  • -Dhttp.proxyHost, -Dhttp.nonProxyHosts and -Dhttp.proxyPort.
  • Selenium RC normally overrides your proxy server configuration, using the Selenium Server as a proxy. Use these options if you need to use your own proxy together with the Selenium Server proxy. selenium.server.options = -port 4545 -proxyInjectionMode
  • selenium.browserLauncher = *pifirefox
  • selenium.browserURL = http://localhost
Twist specific selenium driver options
  • twist.selenium.enableImplicitWait Setting 'twist.selenium.enableImplicitWait' to true is relevant when proxyInjectionMode option is set in selenium.server.options
  • twist.selenium.highlight = true|false
  • twist.selenium.enableImplicitWait = true|false

The Selenium configurations currently not supported in Twist by default are

  1. -log: writes lots of debug information out to a log file
  2. -debug: puts you into debug mode, with more trace information and diagnostics

There is a workaround for using the -log and -debug Selenium options.

Create a file named commons-logging.properties directly under src folder of Twist project, with content

    org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger