Browsers

Introduction

Browser classes define the logic required for your automation driver (eg Puppeteer) to launch or connect to a new browser instance.
There are several provided out of the box, and you are free to define additional ones as necessary.

Configuring Browsers

The default browsers are generally configured correctly for most scenarios, however if your environment is non-standard you may wish to override the default options such as executablePath either with your Env module or Config module.
There are many ways to configure defaults depending on your preferences.

In .env file

1
AUTOMATION_VIEWPORT_WIDTH=1280
2
AUTOMATION_VIEWPORT_HEIGHT=1024
Copied!

In EnvSchema

1
export const EnvSchema = BaseEnvSchema.merge(
2
z.object({
3
// Automation
4
AUTOMATION_VIEWPORT_WIDTH: z.number().default(1280),
5
AUTOMATION_VIEWPORT_HEIGHT: z.number().default(1024),
6
})
7
)
Copied!

Per scenario

The config modules are only the defaults and you can provide any desired configuration when booting the browser.
1
class FooCommand extends Command {
2
public async run() {
3
// Boot a browser with an alternative viewport...
4
const browser: Browser = await this.app.browser(parsed.browser).load({
5
launchOptions: {
6
defaultViewport: {
7
width: 1280,
8
height: 1024,
9
},
10
},
11
})
12
}
13
}
Copied!

Using Browsers

Browsers can be enabled by adding them to your BrowserProvider and we recommend disabling any browsers not in use for performance reasons.
1
import {
2
BraveBrowser,
3
BrowserConstructor,
4
BrowserlessBrowser,
5
ChromeBrowser,
6
EdgeBrowser,
7
BrowserProvider as Provider,
8
} from "@masqueradejs/backstage"
9
10
export class BrowserProvider extends Provider {
11
protected browsers(): Map<string, BrowserConstructor> {
12
return new Map<string, BrowserConstructor>([
13
/*
14
* Local Browsers...
15
*/
16
["chrome", ChromeBrowser],
17
["brave", BraveBrowser],
18
["edge", EdgeBrowser],
19
20
/*
21
* Cloud Browsers...
22
*/
23
["browserless", BrowserlessBrowser],
24
25
/*
26
* Anti-Detect Browsers...
27
*/
28
// ["incognition", IncognitionBrowser],
29
// ["multilogin", MultiLoginBrowser],
30
31
/*
32
* Application Browsers...
33
*/
34
// ["chromelike", ChromelikeBrowser],
35
36
/*
37
* Third-Party Browsers...
38
*/
39
])
40
}
41
}
42
Copied!

Framework Browsers

The following browser definitions are provided out of the box, and can be enabled / disabled in your BrowserProvider service provider class.

Local Browsers

Browser
Platforms
Description
Chrome
Windows, Linux, Mac
Google's flagship browser.
Edge
Windows, Mac
Microsoft's flagship browser.
Brave
Windows, Linux, Mac
Privacy-focused browser.

Anti-Fingerprint Browsers

Anti-Fingerprint browsers are premium solutions that allow developers to manage many hardware profiles from a single machine. We recommend experimenting with local browsers using the Extra-Stealth plugin prior to implementing a paid solution.
Browser
Price Range
Website
MultiLogin
$240 - $1k+/m
Incognition
Free - $149/m
Composing Browsers
Browsers can be defined by extending the core Backstage LocalBrowser or RemoteBrowser class.
1
Copied!