Class Configuration

java.lang.Object
com.codeborne.selenide.Configuration

public class Configuration extends Object
Configuration settings for Selenide default browser
This class is designed so that every setting can be set either via system property or programmatically.
Please note that all fields are static, meaning that every change will immediately reflect in all threads (if you run tests in parallel).

These system properties can be additionally used having effect on every new created browser in test. For example as -D<property>=<value> in command-line

chromeoptions.args - Sets the arguments for chrome options, parameters are comma separated If comma is a part of the value, use double quotes around the argument Non-official list of parameters can be found here.

Example: --no-sandbox,--disable-3d-apis,"--user-agent=Firefox 45, Mozilla"

chromeoptions.prefs - Sets the preferences for chrome options, which are comma separated keyX=valueX preferences. If comma is a part of the value, use double quotes around the preference List of preferences can be found at https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cc

Example: homepage=http://google.com,"intl.allowed_languages=en,ru,es"

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Assertion mode
    static String
    Base url for open() function calls Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.baseUrl=http://myhost".
    static String
    Which browser to use.
    static String
    Sets the path to browser executable.
    static org.openqa.selenium.MutableCapabilities
    Browser capabilities.
    static String
    The browser window position on screen.
    static String
    The browser window size.
    static String
    Which browser version to use (for Internet Explorer).
    static boolean
    ATTENTION! Automatic WebDriver waiting after click isn't working in case of using this feature.
    static String
    Folder to store downloaded files to.
    static boolean
    If set to true, sets value by javascript instead of using Selenium built-in "sendKey" function (that is quite slow because it sends every character separately).
    Defines if files are downloaded via direct HTTP or vie selenide embedded proxy server Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.fileDownload=PROXY"
    Default: HTTPGET
    static boolean
    Enables the ability to run the browser in headless mode.
    static boolean
    If holdBrowserOpen is true, browser window stays open after running tests.
    static String
    Should webdriver wait until page is completely loaded.
    static long
    Timeout for loading a web page (in milliseconds).
    static long
    Interval in milliseconds, when checking if a single element or collection elements are appeared Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.pollingInterval=50"
    Default value: 200 (milliseconds)
    static boolean
    If Selenide should run browser through its own proxy server.
    static String
    Host of Selenide proxy server.
    static int
    Port of Selenide proxy server.
    static String
    URL of remote web driver (in case of using Selenium Grid).
    static long
    Sets connection timeout in milliseconds for remote browser connections.
    static long
    Sets read timeout in milliseconds for remote browser connections.
    static boolean
    Should Selenide re-spawn browser if it's disappeared (hangs, broken, unexpectedly closed).
    static String
    Folder to store screenshots to.
    static String
    Optional: URL of CI server where reports are published to.
    static boolean
    Defines if Selenide saves page source on failing tests.
    static boolean
    Defines if Selenide takes screenshots on failing tests.
    Choose how Selenide should retrieve web elements: using default CSS or Sizzle (CSS3).
    static TextCheck
    Define behaviour of $.shouldHave(text): full text or partial text.
    static long
    Timeout in milliseconds to fail the test, if conditions still not met Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.timeout=10000"
    Default value: 4000 (milliseconds)
    static boolean
    Whether webdriver logs should be enabled.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • baseUrl

      public static String baseUrl
      Base url for open() function calls Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.baseUrl=http://myhost".
      Default value: "http://localhost:8080"
    • timeout

      public static long timeout
      Timeout in milliseconds to fail the test, if conditions still not met Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.timeout=10000"
      Default value: 4000 (milliseconds)
    • pollingInterval

      public static long pollingInterval
      Interval in milliseconds, when checking if a single element or collection elements are appeared Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.pollingInterval=50"
      Default value: 200 (milliseconds)
    • holdBrowserOpen

      public static boolean holdBrowserOpen
      If holdBrowserOpen is true, browser window stays open after running tests. It may be useful for debugging. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.holdBrowserOpen=true".
      Default value: false.
    • reopenBrowserOnFail

      public static boolean reopenBrowserOnFail
      Should Selenide re-spawn browser if it's disappeared (hangs, broken, unexpectedly closed).
      Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.reopenBrowserOnFail=false".
      Set this property to false if you want to disable automatic re-spawning the browser.
      Default value: true
    • browser

      public static String browser
      Which browser to use. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.browser=ie". Supported values: "chrome", "firefox", "ie", "edge", "safari".
      Default value: "chrome"
    • browserVersion

      public static String browserVersion
      Which browser version to use (for Internet Explorer). Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.browserVersion=8".
      Default value: none
    • remote

      public static String remote
      URL of remote web driver (in case of using Selenium Grid). Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.remote=http://localhost:5678/wd/hub".
      Default value: null (Grid is not used).
    • browserSize

      public static String browserSize
      The browser window size. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.browserSize=1024x768".
      Default value: 1366x768
    • browserPosition

      public static String browserPosition
      The browser window position on screen. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.browserPosition=10x10".
      Default value: none
    • browserCapabilities

      public static org.openqa.selenium.MutableCapabilities browserCapabilities
      Browser capabilities. Warning: this capabilities will override capabilities were set by system properties.
      Default value: new MutableCapabilities()
    • pageLoadStrategy

      public static String pageLoadStrategy
      Should webdriver wait until page is completely loaded. Possible values: "none", "normal" and "eager".
      Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.pageLoadStrategy=eager". Default value: "normal".
      - `normal`: return after the load event fires on the new page (it's default in Selenium webdriver); - `eager`: return after DOMContentLoaded fires; - `none`: return immediately
      In some cases `eager` can bring performance boosts for the slow tests. Though, we left default value `normal` because we are afraid to break users' existing tests.
      Since:
      3.5
      See Also:
    • pageLoadTimeout

      public static long pageLoadTimeout
      Timeout for loading a web page (in milliseconds). Default timeout in Selenium WebDriver is 300 seconds (which is incredibly long). Selenide default is 30 seconds.
      Since:
      5.15.0
    • clickViaJs

      public static boolean clickViaJs
      ATTENTION! Automatic WebDriver waiting after click isn't working in case of using this feature. Use clicking via JavaScript instead common element clicking. This solution may be helpful for testing in Internet Explorer. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.clickViaJs=true".
      Default value: false
    • screenshots

      public static boolean screenshots
      Defines if Selenide takes screenshots on failing tests. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.screenshots=false".
      Default value: true
    • savePageSource

      public static boolean savePageSource
      Defines if Selenide saves page source on failing tests. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.savePageSource=false".
      Default value: true
    • reportsFolder

      public static String reportsFolder
      Folder to store screenshots to. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.reportsFolder=test-result/reports".
      Default value: "build/reports/tests" (this is default for Gradle projects)
    • downloadsFolder

      public static String downloadsFolder
      Folder to store downloaded files to. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.downloadsFolder=test-result/downloads".
      Default value: "build/downloads" (this is default for Gradle projects)
    • reportsUrl

      public static String reportsUrl
      Optional: URL of CI server where reports are published to. In case of Jenkins, it is "BUILD_URL/artifact" by default.
      Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.reportsUrl=http://jenkins-host/reports".
      If it's given, names of screenshots are printed as "http://ci.mycompany.com/job/my-job/446/artifact/build/reports/tests/my_test.png" - it's useful to analyze test failures in CI server.
    • fastSetValue

      public static boolean fastSetValue
      If set to true, sets value by javascript instead of using Selenium built-in "sendKey" function (that is quite slow because it sends every character separately).
      Tested on Codeborne projects - works well, speed up ~30%. Some people reported 150% speedup (because sending characters one-by-one was especially slow via network to Selenium Grid on cloud).
      See Feature request #135 Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.fastSetValue=true".
      Default value: false
    • textCheck

      public static TextCheck textCheck
      Define behaviour of $.shouldHave(text): full text or partial text.
      Since:
      6.7.0
    • selectorMode

      public static SelectorMode selectorMode

      Choose how Selenide should retrieve web elements: using default CSS or Sizzle (CSS3).


      Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.selectorMode=Sizzle".


      Possible values: "CSS" or "Sizzle"
      Default value: CSS
      See Also:
    • assertionMode

      public static AssertionMode assertionMode

      Assertion mode

      Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.assertionMode=SOFT".


      Possible values: "STRICT" or "SOFT"
      Default value: STRICT
      See Also:
    • fileDownload

      public static FileDownloadMode fileDownload
      Defines if files are downloaded via direct HTTP or vie selenide embedded proxy server Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.fileDownload=PROXY"
      Default: HTTPGET
    • proxyEnabled

      public static boolean proxyEnabled
      If Selenide should run browser through its own proxy server. It allows some additional features which are not possible with plain Selenium. But it's not enabled by default because sometimes it would not work (more exactly, if tests and browser and executed on different machines, and "test machine" is not accessible from "browser machine"). If it's not your case, I recommend to enable proxy. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.proxyEnabled=true"
      Default: false
    • proxyHost

      public static String proxyHost
      Host of Selenide proxy server. Used only if proxyEnabled == true. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.proxyHost=127.0.0.1"
      Default: empty (meaning that Selenide will detect current machine's ip/hostname automatically)
      See Also:
      • NetworkUtils.getNonLoopbackAddressOfThisMachine()
    • proxyPort

      public static int proxyPort
      Port of Selenide proxy server. Used only if proxyEnabled == true. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.proxyPort=8888"
      Default: 0 (meaning that Selenide will choose a random free port on current machine)
    • webdriverLogsEnabled

      public static boolean webdriverLogsEnabled

      Whether webdriver logs should be enabled.

      These logs may be useful for debugging some webdriver issues. But in most cases they are not needed (and can take quite a lot of disk space), that's why don't enable them by default.

      Default: false
      Since:
      5.18.0
    • headless

      public static boolean headless
      Enables the ability to run the browser in headless mode. Works only for Chrome(59+) and Firefox(56+). Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.headless=true"
      Default: false
    • browserBinary

      public static String browserBinary
      Sets the path to browser executable. Works only for Chrome and Firefox. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.browserBinary=/path/to/binary"
    • remoteReadTimeout

      public static long remoteReadTimeout
      Sets read timeout in milliseconds for remote browser connections. Applies only when remote is specified. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.remoteReadTimeout=180000"
      Default: 90000
      Since:
      6.7.4
    • remoteConnectionTimeout

      public static long remoteConnectionTimeout
      Sets connection timeout in milliseconds for remote browser connections. Applies only when remote is specified. Can be configured either programmatically, via selenide.properties file or by system property "-Dselenide.remoteConnectionTimeout=180000"
      Default: 10000
      Since:
      6.9.0
  • Constructor Details

    • Configuration

      public Configuration()