Class Configuration
- java.lang.Object
-
- com.codeborne.selenide.Configuration
-
public class Configuration extends java.lang.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 additonally used having effect on every new created browser in test. For example as -D
= 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 at https://peter.sh/experiments/chromium-command-line-switches/ 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 static AssertionMode
assertionMode
Assertion mode - STRICT or SOFT Asserts Default value: STRICTstatic java.lang.String
baseUrl
Base url for open() function calls Can be configured either programmatically or by system property "-Dselenide.baseUrl=http://myhost".static java.lang.String
browser
Which browser to use.static java.lang.String
browserBinary
Sets the path to browser executable.static org.openqa.selenium.remote.DesiredCapabilities
browserCapabilities
Browser capabilities.static java.lang.String
browserPosition
The browser window position on screen.static java.lang.String
browserSize
The browser window size.static java.lang.String
browserVersion
Which browser version to use (for Internet Explorer).static boolean
clickViaJs
ATTENTION! Automatic WebDriver waiting after click isn't working in case of using this feature.static boolean
driverManagerEnabled
Controls Selenide and WebDriverManager integration.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).static FileDownloadMode
fileDownload
Defines if files are downloaded via direct HTTP or vie selenide embedded proxy server Can be configured either programmatically or by system property "-Dselenide.fileDownload=PROXY"
Default: HTTPGETstatic boolean
headless
Enables the ability to run the browser in headless mode.static boolean
holdBrowserOpen
If holdBrowserOpen is true, browser window stays open after running tests.static java.lang.String
pageLoadStrategy
Should webdriver wait until page is completely loaded.static long
pollingInterval
Interval in milliseconds, when checking if a single element or collection elements are appeared Can be configured either programmatically or by system property "-Dselenide.pollingInterval=50"
Default value: 200 (milliseconds)static boolean
proxyEnabled
If Selenide should run browser through its own proxy server.static java.lang.String
proxyHost
Host of Selenide proxy server.static int
proxyPort
Port of Selenide proxy server.static java.lang.String
remote
URL of remote web driver (in case of using Selenium Grid).static boolean
reopenBrowserOnFail
Should Selenide re-spawn browser if it's disappeared (hangs, broken, unexpectedly closed).static java.lang.String
reportsFolder
Folder to store screenshots to.static java.lang.String
reportsUrl
Optional: URL of CI server where reports are published to.static boolean
savePageSource
Defines if Selenide saves page source on failing tests.static boolean
screenshots
Defines if Selenide takes screenshots on failing tests.static SelectorMode
selectorMode
Choose how Selenide should retrieve web elements: using default CSS or Sizzle (CSS3)static boolean
startMaximized
The browser window is maximized when started.static long
timeout
Timeout in milliseconds to fail the test, if conditions still not met Can be configured either programmatically or by system property "-Dselenide.timeout=10000"
Default value: 4000 (milliseconds)static boolean
versatileSetValue
If set to true, 'setValue' and 'val' methods of SelenideElement can work as 'selectOptionByValue', 'selectRadio' depending on the real control type, defined by element's tag.
-
Constructor Summary
Constructors Constructor Description Configuration()
-
-
-
Field Detail
-
baseUrl
public static java.lang.String baseUrl
Base url for open() function calls Can be configured either programmatically 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 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 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 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 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 java.lang.String browser
Which browser to use. Can be configured either programmatically or by system property "-Dselenide.browser=ie". Supported values: "chrome", "firefox", "legacy_firefox", "ie", "htmlunit", "phantomjs", "opera", "safari", "edge", "jbrowser"
Default value: "chrome"
-
browserVersion
public static java.lang.String browserVersion
Which browser version to use (for Internet Explorer). Can be configured either programmatically or by system property "-Dselenide.browserVersion=8".
Default value: none
-
remote
public static java.lang.String remote
URL of remote web driver (in case of using Selenium Grid). Can be configured either programmatically or by system property "-Dselenide.remote=http://localhost:5678/wd/hub".
Default value: null (Grid is not used).
-
browserSize
public static java.lang.String browserSize
The browser window size. Can be configured either programmatically or by system property "-Dselenide.browserSize=1024x768".
Default value: 1366x768
-
browserPosition
public static java.lang.String browserPosition
The browser window position on screen. Can be configured either programmatically or by system property "-Dselenide.browserPosition=10x10".
Default value: none
-
startMaximized
public static boolean startMaximized
The browser window is maximized when started. Can be configured either programmatically or by system property "-Dselenide.startMaximized=true".
Default value: false
-
browserCapabilities
public static org.openqa.selenium.remote.DesiredCapabilities browserCapabilities
Browser capabilities. Warning: this capabilities will override capabilities were set by system properties.
Default value: DesiredCapabilities::new
-
pageLoadStrategy
public static java.lang.String pageLoadStrategy
Should webdriver wait until page is completely loaded. Possible values: "none", "normal" and "eager".
Can be configured either programmatically 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 afraid to break users' existing tests.
See https://w3c.github.io/webdriver/webdriver-spec.html#dfn-page-loading-strategy- Since:
- 3.5
-
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 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 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 or by system property "-Dselenide.savePageSource=false".
Default value: true
-
reportsFolder
public static java.lang.String reportsFolder
Folder to store screenshots to. Can be configured either programmatically or by system property "-Dselenide.reportsFolder=test-result/reports".
Default value: "build/reports/tests" (this is default for Gradle projects)
-
reportsUrl
public static java.lang.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 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).
https://github.com/codeborne/selenide/issues/135 Can be configured either programmatically or by system property "-Dselenide.fastSetValue=true".
Default value: false
-
versatileSetValue
public static boolean versatileSetValue
If set to true, 'setValue' and 'val' methods of SelenideElement can work as 'selectOptionByValue', 'selectRadio' depending on the real control type, defined by element's tag.
Will decrease performance of setValue, make it slower, but will also make tests implementation more "business oriented". With this property being set to true, tests may no longer be dependent on actual control implementation in html and be more abstract.
https://github.com/codeborne/selenide/issues/508 Can be configured either programmatically or by system property "-Dselenide.versatileSetValue=true".
Default value: false
-
selectorMode
public static SelectorMode selectorMode
Choose how Selenide should retrieve web elements: using default CSS or Sizzle (CSS3)
-
assertionMode
public static AssertionMode assertionMode
Assertion mode - STRICT or SOFT Asserts Default value: STRICT- See Also:
AssertionMode
-
fileDownload
public static FileDownloadMode fileDownload
Defines if files are downloaded via direct HTTP or vie selenide embedded proxy server Can be configured either programmatically 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 or by system property "-Dselenide.proxyEnabled=true"
Default: false
-
proxyHost
public static java.lang.String proxyHost
Host of Selenide proxy server. Used only if proxyEnabled == true. Can be configured either programmatically or by system property "-DproxyHost=127.0.0.1"
Default: empty (meaning that Selenide will detect current machine's ip/hostname automatically)- See Also:
ClientUtil.getConnectableAddress()
-
proxyPort
public static int proxyPort
Port of Selenide proxy server. Used only if proxyEnabled == true. Can be configured either programmatically or by system property "-Dselenide.proxyPort=8888"
Default: 0 (meaning that Selenide will choose a random free port on current machine)
-
driverManagerEnabled
public static boolean driverManagerEnabled
Controls Selenide and WebDriverManager integration. When integration is enabled you don't need to download and setup any browser driver executables. See https://github.com/bonigarcia/webdrivermanager for WebDriverManager configuration details. Can be configured either programmatically or by system property "-Dselenide.driverManagerEnabled=false"
Default: true
-
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 or by system property "-Dselenide.headless=true"
Default: false
-
browserBinary
public static java.lang.String browserBinary
Sets the path to browser executable. Works only for Chrome, Firefox and Opera. Can be configured either programmatically or by system property "-Dselenide.browserBinary=/path/to/binary"
-
-