Playwright Options
This page lists various options that you can use to customise your Playwright sessions on TestingBot.
Basic Settings
Browser Name
The name of the browser to run your Playwright test on. TestingBot currently supports these browserNames:.
- Chrome
- Edge
- Firefox
- Safari (WebKit)
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest'
}
const browser = await playwright.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'edge',
browserVersion: 'latest'
}
const browser = await playwright.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'firefox',
browserVersion: 'latest'
}
const browser = await playwright.firefox.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'safari',
browserVersion: 'latest'
}
const browser = await playwright.webkit.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Browser Version
The version of the browser to run your Playwright test on.
-
"version": "*"
: If you use*
as version, TestingBot will pick a random version. -
"version": "latest"
: TestingBot will automatically take the latest version. You can also uselatest-1
,latest-2
, ... to test on the next most recent versions. For example, if the current latest Chrome version is 89 and you uselatest-2
, then the test will run on Chrome 87. -
"version": "<=16"
: TestingBot will pick a version smaller than or equal to the version you specify with<=
.
"version": "16>="
: TestingBot will pick a version higher than or equal to the version you specify with>=
.
Browser Platform
The OS/platform for the test VM which will run the Playwright test.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
platform: 'WIN10'
}
const browser = await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
-
WIN10
-
LINUX
-
BIGSUR
-
MONTEREY
Make a video of your tests
By default we record a video of your test, which is accessible in the member area.
If you do not wish to have this, you can disable it with this option.
Video should not slow down your test considerably.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
screenRecorder: false
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type | Default Value |
---|---|
boolean | true |
Test Privacy
Make the test results for this test public so that everyone can access the results.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
public: true
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type | Default Value |
---|---|
boolean | false |
Blacklist hostnames
The hostnames you specify will be pointed to localhost instead of their real destination. This means you can speed up tests by blocking third party content which you don't need and slows down your test.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
blacklist: 'site1.com,site2.com'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type |
---|
string (comma-separated) |
Customize Logging
By default, TestingBot records logs of all Playwright actions.
Set this option to false
if you don't want TestingBot to record anything (for example, if you have sensitive data).
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
recordLogs: true
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type | Default Value | Possible Values: |
---|---|---|
boolean | true |
true , false
|
Custom Time Zones
Change the Time Zone of the Virtual Machine to the Time Zone you specify. You can find a list of timezones on Wikipedia. Only location names are supported (not their paths). See some examples below:
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
timeZOne: 'Etc/UTC'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type | Default Value | Possible Values: |
---|---|---|
string | "Etc/UTC" | List of timezones |
Change Screen Resolution
Will adjust the screen resolution before your test.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
'screen-resolution': '1280x1024'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type | Default Value | |||||||
---|---|---|---|---|---|---|---|---|
string | "1280x1024" |
|
Geolocation Testing
We provide an option where you can specify from which country you'd like to run the test from.
Once you specify this option, the virtual machine we provision for your test will be configured to use a proxy in the country you specified.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
geoCountryCode: 'US'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
We currently support the following country codes:
- '*': this will take a random country from the list below
- 'AU': Australia
- 'BH': Bahrain
- 'BE': Belgium
- 'BR': Brazil
- 'CN': China
- 'FR': France
- 'DE': Germany
- 'IN': India
- 'IT': Italy
- 'JP': Japan
- 'SG': Singapore
- 'ZA': South Africa
- 'ES': Spain
- 'SE': Sweden
- 'AE': United Arab Emirates
- 'GB': United Kingdom
- 'US': United States
Upload
This option allows you to upload a file to the test VM running the Playwright test.
TestingBot will first download the file from the URL you specified and save it on the test VM so your test can use the file.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
upload: 'https://testingbot.com/assets/logo-head.png',
uploadFilepath: '/tmp/test.log'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
const page = await browser.newPage()
await page.goto('http://localhost:3000')
await page.locator('input[name="file-upload"]').click()
await page.locator('input[name="file-upload"]').setInputFiles('/tmp/test.png')
await page.click('upload-button')
browser.close()
You need specify the download URL as
upload
and useuploadFilepath
to indicate where TestingBot needs to put the file.
Change Playwright Version
By default, TestingBot will use the same Playwright version as the one that is running your test.
If for some reason you need to specify a different version, you can use the playwrightVersion
option.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
'playwright:options': {
playwrightVersion: '1.35.0'
},
browserName: 'chrome',
browserVersion: 'latest',
name: 'First Test'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Change Test Name
Add a name to this test, which will show up in our member area and API.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
name: 'First Test'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type | Default Value |
---|---|
string | unnamed test |
Group Tests
A key you can use to group certain tests in the same build (for example in Jenkins).
The builds will appear in our member area.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
build: 'First Build'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type |
---|
string |
Timeout
Control the timeout setting of the session. This setting, specified in seconds, controls when a session times out.
A timeout occurs when a session has not received any commands from your Playwright test for the xx amount of seconds specified.
If a certain Playwright command takes longer than the specified setting, the session will automatically close.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET,
timeout: 90
},
browserName: 'chrome',
browserVersion: 'latest'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type | Default Value |
---|---|
int (specify number of seconds) | 90 seconds |
Maximum Test Duration
The maximum duration for a single test. This is a safeguard to prevent bad tests from using up your credits.
We generally recommend to keep tests short (less than 10 minutes). It's better to split up large tests in smaller individual tests.
This keeps your tests fast and allows for more parallelization of your tests.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
maxduration: 1800
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type | Default Value |
---|---|
int (specify number of seconds) | 1800 seconds (30 minutes) |
Custom Metadata
Send along custom data, for example your release, server, commit hash, ...
This will show up on the test detail page in the TestingBot member area.
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
extra: 'Extra Information'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
Value Type |
---|
string |
Startup Flags
You can customize the startup flags of the browser by passing in extra flags.
This is identical to passing args
with Playwright.
const startupFlags = []
startupFlags.push('--window-size=1280,720')
startupFlags.push('--hide-scrollbars')
const browser = await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com` +
`/playwright?key=api_key&secret=api_secret&browserName=chrome&startupFlags=${JSON.stringify(startupFlags)}`
})
const page = await browser.newPage()
await page.goto('https://testingbot.com')
browser.close()
TestingBot Tunnel
You can specify the tunnelIdentifier
to use Playwright with TestingBot Tunnel.
const pw = require('playwright-core')
(async () => {
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
browserName: 'chrome',
browserVersion: 'latest',
tunnelIdentifier: 'myPlaywrightTunnel'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
const context = await browser.newContext()
const page = await context.newPage()
await page.goto('http://localhost:3000/')
await page.screenshot({ path: 'screenshot.png' })
await browser.close()
})()
By default we support proxying these ports for localhost testing:
[443, 80, 8080, 3030, 3000, 3001]
.
If you need additional ports, please pass an array of port numbers to eitherlocalHttpPorts
orlocalHttpsPorts
Firefox Preferences
You can pass in the firefoxPreferences which Playwright accepts.
const pw = require('playwright-core')
(async () => {
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
'playwright:options': {
firefoxPreferences: ''
},
browserName: 'firefox',
browserVersion: 'latest'
}
await pw.firefox.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
})()
Devtools
You can pass in the devTools which Playwright accepts. This is a Chromium-only option which decices whether to auto-open a Developer Tools panel for each tab during the test.
const pw = require('playwright-core')
(async () => {
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET
},
'playwright:options': {
devtools: true
},
browserName: 'chrome',
browserVersion: 'latest'
}
await pw.chromium.connect({
wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
})()