browsers
Overview
The browsers section is mandatory in Testplane settings. It specifies all the browsers in which the tests will run.
Setup
This section has the following format:
import type { ConfigInput } from "testplane";
export default {
browsers: {
"<browser-id>": {
desiredCapabilities: {
browserName: "<browser-name>",
// ...
},
// ...
},
},
} satisfies ConfigInput;
Where <browser-id> is the name of the browser used for its identification.
To avoid repeating the same settings for different browsers, you can set all the default values you need at the root of the Testplane config. For example:
import type { ConfigInput } from "testplane";
export default {
sessionsPerBrowser: 10,
browsers: {
chrome: {
/* ... */
},
firefox: {
// ...
sessionsPerBrowser: 5,
},
},
} satisfies ConfigInput;
In this example, the value 10 will be used for the sessionsPerBrowser option for chrome, and 5 for firefox.
Main browser settings
| Parameter | Type | Default | Description |
desiredCapabilities | DesiredCapabilities | N/A | Required parameter. Specifies the properties that the browser must have. Used by WebDriver, see DesiredCapabilities. |
gridUrl | string |
| Selenium grid URL. |
baseUrl | string | "http://localhost" | Base URL of the service being tested. |
browserWSEndpoint | string | null | Websocket endpoint for connecting to the browser via Chrome DevTools Protocol (CDP). |
automationProtocol | string | "webdriver" | Protocol for communication with the browser. See WebDriver vs CDP. |
sessionEnvFlags | SessionEnvFlags | {} | Environment flags setting the protocol to be used in the created browser session. |
windowSize | string | WindowSize | null | Browser window size. |
headless | boolean | "new" | "old" | depends on browser | Allows running the browser in headless mode. |
desiredCapabilities
Required parameter. Specifies the properties that the browser must have.
The format of the desiredCapabilities object is defined by the WebDriver standard.
In addition to standard options, some tools provide specific settings in their namespaces.
Browser-specific options:
- Chrome,
goog:chromeOptions— ChromeDriver options documentation - Firefox,
moz:firefoxOptions— Geckodriver documentation - Edge,
ms:edgeOptions— EdgeDriver documentation
Grid-specific browser options:
- Sauce Labs,
sauce:options— documentation - BrowserStack,
bstack:options— documentation - TestingBot,
tb:options— documentation
Options specific to some automation tools:
- Appium,
appium:*— documentation - Selenoid,
selenoid:options— documentation
Example of an extended desiredCapabilities setting:
import type { ConfigInput } from "testplane";
export default {
browsers: {
chrome: {
desiredCapabilities: {
browserName: "chrome",
browserVersion: "125.0",
"goog:chromeOptions": {
args: ["--hide-scrollbars", "--headless=new"],
},
},
},
},
} satisfies ConfigInput;
gridUrl
Grid URL (the address where ChromeDriver/Selenium Standalone/Sauce Labs/etc. listens).
Default: http://localhost:4444/wd/hub.
You can also use value "local" in order to use local browsers, managed by Testplane. Read more
in guide How to launch Testplane in the local browser.
baseUrl
Base URL of the service being tested. Allows for more convenient use of the browser.url commands:
- if the target address starts with
/,baseUrlwithout the path part will be added at the beginning. - if the target address does not start with
/, the entirebaseUrlwill be added at the beginning.
Default: http://localhost.
browserWSEndpoint
Websocket endpoint for connecting to the browser via Chrome DevTools Protocol (CDP). For example, you specify browserWSEndpoint: "ws://YOUR_HOST/devtools", to which the browser session identifier will be added at the end: ws://YOUR_HOST/devtools/12345, where 12345 is the session identifier.
Default value: null. It means that Testplane will try to determine the websocket endpoint automatically.
automationProtocol
Protocol for communication with the browser. Available values: webdriver and devtools. See also WebDriver vs CDP. Default: webdriver.
sessionEnvFlags
Environment flags set the protocols that will be used in the created browser session. By default, environment flags are automatically set according to the specified desiredCapabilities. However, in rare cases, they may have incorrect values and can be explicitly set using this option.
Available flags:
| Flag | Protocols |
isW3C | WebDriverProtocol or by default JsonWProtocol |
isChrome | ChromiumProtocol |
isMobile | |
isSauce | Sauce Labs specific commands |
isSeleniumStandalone | Special Selenium commands when running tests in Selenium Grid or using Selenium Standalone Server. |
For example:
import type { ConfigInput } from "testplane";
export default {
browsers: {
"chrome-phone": {
// ...
sessionEnvFlags: {
isMobile: true,
},
},
},
} satisfies ConfigInput;
windowSize
Browser window size. If not specified, the window size will depend on WebDriver. Can be specified as a string, for example, 800x1000 or as an object with width and height keys with integer values.
For example:
const browserOptions = {
windowSize: "800x1000",
};
and
const browserOptions = {
windowSize: {
width: 800,
height: 1000,
},
};
are equivalent.
Setting the resolution for the Opera browser or for mobile browsers does not work as these browsers only use fullscreen mode.
headless
Allows managing the browser's headless mode (without visible browser display). Can be set as a boolean value, and from Chrome version 112, can be set as a string "new" | "old". More about the new headless mode — in Chrome blog.
Default: null (determined on the browser side).
Timeouts
| Parameter | Type | Default | Description |
waitTimeout | number | 3000 | Timeout for events on the web page, in ms. |
waitInterval | number | 500 | Interval for events on the web page, in ms. |
httpTimeout | number | 30000 | Timeout for any requests to the Selenium server, in ms. |
urlHttpTimeout | number | = httpTimeout | Timeout for the /url request to the Selenium server, in ms. |
pageLoadTimeout | number | 20000 | Timeout for the full page load, in ms. |
sessionRequestTimeout | number | = httpTimeout | Timeout for the browser session request, in ms. |
sessionQuitTimeout | number | 5000 | Timeout for ending the session, in ms. |
testTimeout | number | null | Timeout for running the test, in ms. If the value is not set, the general timeout for all browsers will be used, which is set with the system.mochaOpts.timeout setting. |
waitTimeout
Timeout for events on the web page, in milliseconds. Default: 3000 ms (3 seconds).
Applied in the waitUntil command, which is used in all waitFor* commands when searching for a specified element on the page.
For example, when executing the browser.$('.element').click() command, the $('element') subcommand will, by default, wait for the element's existence up to 3000 ms before clicking it.
waitInterval
Interval for events on the web page, in milliseconds. Default: 500 ms.
Applied in the waitUntil command, which is used in all waitFor* commands when searching for a specified element on the page.
For example, when executing the browser.$('.element').click() command, the $('element') subcommand will, by default, check for the existence of the element every 500 ms.
httpTimeout
Timeout for any requests to the Selenium server, in milliseconds. Default: 30000 ms.
urlHttpTimeout
Timeout for the /url request to the Selenium server, in milliseconds. Sometimes, when opening a link on the server side, a lot of logic is executed in middleware, causing the link to take a long time to open. To avoid increasing the timeout for all commands due to this, Testplane allows you to set a separate timeout for the /url request.
pageLoadTimeout
Timeout for the full page load, in milliseconds. Default: 20000 ms.
sessionRequestTimeout
Timeout for the browser session request, in milliseconds. By default, it takes the value of the httpTimeout setting.
sessionQuitTimeout
Timeout for ending the session, in milliseconds. Default: 5000 ms.
testTimeout
Timeout for running the test, in milliseconds. When used for a test suite, it will apply to all tests and hooks within that suite.
If the value is not set, the general timeout for all browsers, set with the system.mochaOpts.timeout setting, will be used.
Running Tests
| Parameter | Type | Default | Description |
sessionsPerBrowser | number | 1 | Number of sessions that will be run simultaneously for a particular browser. |
testsPerSession | number | Infinity | How many tests can be run sequentially in one browser session. This parameter limits the reuse of the session to prevent test failures due to browser degradation, and has nothing to do with parallel test execution. |
retry | number | 0 | How many times to retry a failing test. |
shouldRetry | (data: FailedTestData) => boolean | see description | Function that determines if a retry is needed. By default, a function is set that returns true if retry > 0 and false if retry == 0. |
strictTestsOrder | boolean | false | Guarantee strict order of tests. If true, the API function testplane.readTests will always return the same result. |
passive | boolean | false | Allows making the browser passive. In passive browsers, tests do not run by default. Available since testplane@8.16.0. Warning: it currently has issues, read below. |
openAndWaitOpts | OpenAndWaitOpts | see description | Allows setting default options for the browser.openAndWait command. |
isolation | boolean | true for Chrome 93+ | Enables isolation mode using browser contexts. |
sessionsPerBrowser
Number of sessions that will be run simultaneously for a particular browser. Default: 1.
testsPerSession
This parameter specifies how many tests can be run sequentially in one browser session. It can be useful to limit the reuse of the session. If the same browser session is used many times for running different tests, at some point the browser may start to degrade. This can affect the test run, leading to failures. Once the limit of tests is reached, the session will be closed and a new session will start.
Default: Infinity. This means the session will be reused an infinite number of times. However, in real operations, there may be limitations from the grid on which the browsers are running. For example, the grid may limit the maximum lifetime of a session, and then the number of tests that can be run within a session will be determined by its lifetime.
Be careful: this parameter has nothing to do with parallel test execution.
retry
How many times to retry a test if it fails. Default: 0.