browser.createUserContext commandThe browser.createUserContext command of the browser module creates a new user context in the browser.
/* Without optional parameters */
{
"method": "browser.createUserContext",
"params": {}
}
/* With optional parameters */
{
"method": "browser.createUserContext",
"params": {
"acceptInsecureCerts": true,
"proxy": {
"proxyType": "manual",
"httpProxy": "127.0.0.1:80"
},
"unhandledPromptBehavior": {
"default": "accept"
}
}
}Set params to an empty object ({}) or include any of the following optional fields:
acceptInsecureCerts OptionalA boolean that controls whether untrusted TLS certificates (for example, self-signed or expired) are accepted within this user context. When set, it overrides the session-level acceptInsecureCerts setting for this user context.
proxy OptionalAn object that specifies the proxy configuration the browser should use for network requests within this user context. When set, it overrides the session-level proxy setting for this user context.
unhandledPromptBehavior OptionalAn object that specifies the default behavior when a user prompt (such as an alert, confirm, or prompt dialog) is encountered within this user context. When set, it overrides the session-level unhandledPromptBehavior setting for this user context.
Note: When a parameter is set, it applies to all existing and future tabs within this user context.
The following field in the result object of the response describes the created user context:
userContextA string that contains the ID that uniquely identifies the created user context.
invalid argumentA required parameter is missing or has an invalid type.
unsupported operationacceptInsecureCerts is true but the browser does not support accepting insecure TLS connections, or proxy is specified but the browser cannot configure proxy settings for this user context or cannot apply the given proxy configuration.
With a WebDriver BiDi connection and an active session, send the following message to create a user context:
{
"id": 1,
"method": "browser.createUserContext",
"params": {}
}The browser responds with a successful user context creation as follows:
{
"id": 1,
"type": "success",
"result": {
"userContext": "4e4b1f6d-3f1a-4b2e-9f8c-1a2b3c4d5e6f"
}
}Send the following message to create a user context that routes network requests through a proxy:
{
"id": 2,
"method": "browser.createUserContext",
"params": {
"proxy": {
"proxyType": "manual",
"httpProxy": "127.0.0.1:80"
}
}
}The browser responds with a successful user context creation as follows:
{
"id": 2,
"type": "success",
"result": {
"userContext": "7d9e2a1b-5c3f-4e6d-8a7b-2c1d0e9f8a7b"
}
}session.new commandbrowser.getUserContexts commandbrowser.removeUserContext command