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. - it is important whether
/exists (or not). See more.
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.
Starting from Testplane 9, the value "devtools" has been removed. It caused a number of hard-to-reproduce errors that never occurred under "webdriver", and the underlying WebdriverIO has also dropped its devtools automation protocol. The only supported value is now "webdriver".
To launch tests in a locally installed browser, use gridUrl: "local" instead — Testplane will automatically download the required browser and driver and start it via WebDriver. See the Running on Local Browsers blog post for a step-by-step guide.
This change does not affect the Chrome DevTools Protocol itself — you can still use CDP from your tests, see the How to Use Chrome DevTools Protocol guide.
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.