跳到主要内容

WebDriver Bidi 协议

这些协议命令是基于当前活跃的WebDriver Bidi规范生成的。要为您的测试启用此协议,请确保在您的capabilities中设置webSocketUrl: true。

谨慎使用!

浏览器支持不能保证,接口可能会在未来发生变化。该标准目前正在开发中,浏览器厂商将根据自己的时间表添加这些功能。

最后更新时间:2025年4月26日星期六 17:10:07 GMT-0700(太平洋夏令时间)


send​

通过WebDriver Bidi发送套接字命令

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.send(params)
参数​
名称类型详情
paramsCommandData套接字载荷
返回​
  • <Object> CommandResponse: WebDriver Bidi响应

sendAsync​

通过WebDriver Bidi发送异步套接字命令

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.sendAsync(params)
参数​
名称类型详情
paramsCommandData套接字载荷
返回​
  • <Number> id: WebDriver Bidi请求的id

sessionStatus​

WebDriver Bidi命令,用于发送命令方法"session.status"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.sessionStatus(params)
参数​
名称类型详情
paramsremote.EmptyParams
{}
返回​
  • <Object> local.SessionStatusResult: 命令返回值,具有以下接口:
    {
    ready: boolean;
    message: string;
    }

sessionNew​

WebDriver Bidi命令,用于发送命令方法"session.new"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.sessionNew(params)
参数​
名称类型详情
paramsremote.SessionNewParameters
{
capabilities: SessionCapabilitiesRequest;
}
返回​
  • <Object> local.SessionNewResult: 命令返回值,具有以下接口:
    {
    sessionId: string;
    capabilities: {
    acceptInsecureCerts: boolean;
    browserName: string;
    browserVersion: string;
    platformName: string;
    setWindowRect: boolean;
    userAgent: string;
    proxy?: SessionProxyConfiguration;
    webSocketUrl?: string;
    };
    }

sessionEnd​

WebDriver Bidi命令,用于发送命令方法"session.end"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.sessionEnd(params)
参数​
名称类型详情
paramsremote.EmptyParams
{}

sessionSubscribe​

WebDriver Bidi命令,用于发送命令方法"session.subscribe"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.sessionSubscribe(params)
参数​
名称类型详情
paramsremote.SessionSubscriptionRequest
{
events: string[];
contexts?: BrowsingContextBrowsingContext[];
}

sessionUnsubscribe​

WebDriver Bidi命令,用于发送命令方法"session.unsubscribe"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.sessionUnsubscribe(params)
参数​
名称类型详情
paramsremote.SessionSubscriptionRequest
{
events: string[];
contexts?: BrowsingContextBrowsingContext[];
}

browserClose​

WebDriver Bidi命令,用于发送命令方法"browser.close"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browserClose(params)
参数​
名称类型详情
paramsremote.EmptyParams
{}

browserCreateUserContext​

WebDriver Bidi命令,用于发送命令方法"browser.createUserContext"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browserCreateUserContext(params)
参数​
名称类型详情
paramsremote.EmptyParams
{}
返回​
  • <Object> local.BrowserCreateUserContextResult: 命令返回值,具有以下接口:
    ;

browserGetUserContexts​

WebDriver Bidi命令,用于发送命令方法"browser.getUserContexts"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browserGetUserContexts(params)
参数​
名称类型详情
paramsremote.EmptyParams
{}
返回​
  • <Object> local.BrowserGetUserContextsResult: 命令返回值,具有以下接口:
    {
    userContexts: BrowserUserContextInfo[];
    }

browserRemoveUserContext​

WebDriver Bidi命令,用于发送命令方法"browser.removeUserContext"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browserRemoveUserContext(params)
参数​
名称类型详情
paramsremote.BrowserRemoveUserContextParameters
{
userContext: BrowserUserContext;
}

browsingContextActivate​

WebDriver Bidi命令,用于发送命令方法"browsingContext.activate"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextActivate(params)
参数​
名称类型详情
paramsremote.BrowsingContextActivateParameters
{
context: BrowsingContextBrowsingContext;
}

browsingContextCaptureScreenshot​

WebDriver Bidi命令,用于发送命令方法"browsingContext.captureScreenshot"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextCaptureScreenshot(params)
参数​
名称类型详情
paramsremote.BrowsingContextCaptureScreenshotParameters
{
context: BrowsingContextBrowsingContext;
/**
* @default 'viewport'
*/
origin?: "viewport" | "document";
format?: BrowsingContextImageFormat;
clip?: BrowsingContextClipRectangle;
}
返回​
  • <Object> local.BrowsingContextCaptureScreenshotResult: 命令返回值,具有以下接口:
    {
    data: string;
    }

browsingContextClose​

WebDriver Bidi命令,用于发送命令方法"browsingContext.close"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextClose(params)
参数​
名称类型详情
paramsremote.BrowsingContextCloseParameters
{
context: BrowsingContextBrowsingContext;
promptUnload?: boolean;
}

browsingContextCreate​

WebDriver Bidi命令,用于发送命令方法"browsingContext.create"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextCreate(params)
参数​
名称类型详情
paramsremote.BrowsingContextCreateParameters
{
type: BrowsingContextCreateType;
referenceContext?: BrowsingContextBrowsingContext;
background?: boolean;
userContext?: BrowserUserContext;
}
返回​
  • <Object> local.BrowsingContextCreateResult: 命令返回值,具有以下接口:
    {
    context: BrowsingContextBrowsingContext;
    }

browsingContextGetTree​

WebDriver Bidi命令,用于发送命令方法"browsingContext.getTree"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextGetTree(params)
参数​
名称类型详情
paramsremote.BrowsingContextGetTreeParameters
{
maxDepth?: JsUint;
root?: BrowsingContextBrowsingContext;
}
返回​
  • <Object> local.BrowsingContextGetTreeResult: 命令返回值,具有以下接口:
    {
    contexts: BrowsingContextInfoList;
    }

browsingContextHandleUserPrompt​

WebDriver Bidi命令,用于发送命令方法"browsingContext.handleUserPrompt"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextHandleUserPrompt(params)
参数​
名称类型详情
paramsremote.BrowsingContextHandleUserPromptParameters
{
context: BrowsingContextBrowsingContext;
accept?: boolean;
userText?: string;
}

browsingContextLocateNodes​

WebDriver Bidi命令,用于发送命令方法"browsingContext.locateNodes"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextLocateNodes(params)
参数​
名称类型详情
paramsremote.BrowsingContextLocateNodesParameters
{
context: BrowsingContextBrowsingContext;
locator: BrowsingContextLocator;
maxNodeCount?: JsUint;
serializationOptions?: ScriptSerializationOptions;
startNodes?: ScriptSharedReference[];
}
返回​
  • <Object> local.BrowsingContextLocateNodesResult: 命令返回值,具有以下接口:
    {
    nodes: ScriptNodeRemoteValue[];
    }

browsingContextNavigate​

WebDriver Bidi命令,用于发送命令方法"browsingContext.navigate"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextNavigate(params)
参数​
名称类型详情
paramsremote.BrowsingContextNavigateParameters
{
context: BrowsingContextBrowsingContext;
url: string;
wait?: BrowsingContextReadinessState;
}
返回​
  • <Object> local.BrowsingContextNavigateResult: 命令返回值,具有以下接口:
    {
    navigation: BrowsingContextNavigation | null;
    url: string;
    }

browsingContextPrint​

WebDriver Bidi命令,用于发送命令方法"browsingContext.print"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextPrint(params)
参数​
名称类型详情
paramsremote.BrowsingContextPrintParameters
{
context: BrowsingContextBrowsingContext;
background?: boolean;
margin?: BrowsingContextPrintMarginParameters;
/**
* @default 'portrait'
*/
orientation?: "portrait" | "landscape";
page?: BrowsingContextPrintPageParameters;
pageRanges?: (JsUint | string)[];
/**
* @default 1
*/
scale?: number;
/**
* @default true
*/
shrinkToFit?: boolean;
}
返回​
  • <Object> local.BrowsingContextPrintResult: 命令返回值,具有以下接口:
    {
    data: string;
    }

browsingContextReload​

WebDriver Bidi命令,用于发送命令方法"browsingContext.reload"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextReload(params)
参数​
名称类型详情
paramsremote.BrowsingContextReloadParameters
{
context: BrowsingContextBrowsingContext;
ignoreCache?: boolean;
wait?: BrowsingContextReadinessState;
}

browsingContextSetViewport​

WebDriver Bidi命令,用于发送命令方法"browsingContext.setViewport"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextSetViewport(params)
参数​
名称类型详情
paramsremote.BrowsingContextSetViewportParameters
{
context: BrowsingContextBrowsingContext;
viewport?: BrowsingContextViewport | null;
devicePixelRatio?: number | null;
}

browsingContextTraverseHistory​

WebDriver Bidi命令,用于发送命令方法"browsingContext.traverseHistory"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.browsingContextTraverseHistory(params)
参数​
名称类型详情
paramsremote.BrowsingContextTraverseHistoryParameters
{
context: BrowsingContextBrowsingContext;
delta: JsInt;
}

networkAddIntercept​

WebDriver Bidi命令,用于发送命令方法"network.addIntercept"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.networkAddIntercept(params)
参数​
名称类型详情
paramsremote.NetworkAddInterceptParameters
{
phases: NetworkInterceptPhase[];
contexts?: BrowsingContextBrowsingContext[];
urlPatterns?: NetworkUrlPattern[];
}
返回​
  • <Object> local.NetworkAddInterceptResult: 命令返回值,具有以下接口:
    {
    intercept: NetworkIntercept;
    }

networkContinueRequest​

WebDriver Bidi命令,用于发送命令方法"network.continueRequest"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.networkContinueRequest(params)
参数​
名称类型详情
paramsremote.NetworkContinueRequestParameters
{
request: NetworkRequest;
body?: NetworkBytesValue;
cookies?: NetworkCookieHeader[];
headers?: NetworkHeader[];
method?: string;
url?: string;
}

networkContinueResponse​

WebDriver Bidi命令,用于发送命令方法"network.continueResponse"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.networkContinueResponse(params)
参数​
名称类型详情
paramsremote.NetworkContinueResponseParameters
{
request: NetworkRequest;
cookies?: NetworkSetCookieHeader[];
credentials?: NetworkAuthCredentials;
headers?: NetworkHeader[];
reasonPhrase?: string;
statusCode?: JsUint;
}

networkContinueWithAuth​

WebDriver Bidi命令,用于发送命令方法"network.continueWithAuth"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.networkContinueWithAuth(params)
参数​
名称类型详情
paramsremote.NetworkContinueWithAuthParameters
{
request: NetworkRequest;
}

networkFailRequest​

WebDriver Bidi命令,用于发送命令方法"network.failRequest"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.networkFailRequest(params)
参数​
名称类型详情
paramsremote.NetworkFailRequestParameters
{
request: NetworkRequest;
}

networkProvideResponse​

WebDriver Bidi命令,用于发送命令方法"network.provideResponse"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.networkProvideResponse(params)
参数​
名称类型详情
paramsremote.NetworkProvideResponseParameters
{
request: NetworkRequest;
body?: NetworkBytesValue;
cookies?: NetworkSetCookieHeader[];
headers?: NetworkHeader[];
reasonPhrase?: string;
statusCode?: JsUint;
}

networkRemoveIntercept​

WebDriver Bidi命令,用于发送命令方法"network.removeIntercept"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.networkRemoveIntercept(params)
参数​
名称类型详情
paramsremote.NetworkRemoveInterceptParameters
{
intercept: NetworkIntercept;
}

scriptAddPreloadScript​

WebDriver Bidi命令,用于发送命令方法"script.addPreloadScript"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.scriptAddPreloadScript(params)
参数​
名称类型详情
paramsremote.ScriptAddPreloadScriptParameters
{
functionDeclaration: string;
arguments?: ScriptChannelValue[];
contexts?: BrowsingContextBrowsingContext[];
sandbox?: string;
}
返回​
  • <Object> local.ScriptAddPreloadScriptResult: 命令返回值,具有以下接口:
    {
    script: ScriptPreloadScript;
    }

scriptDisown​

WebDriver Bidi命令,用于发送命令方法"script.disown"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.scriptDisown(params)
参数​
名称类型详情
paramsremote.ScriptDisownParameters
{
handles: ScriptHandle[];
target: ScriptTarget;
}

scriptCallFunction​

WebDriver Bidi命令,用于发送命令方法"script.callFunction"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.scriptCallFunction(params)
参数​
名称类型详情
paramsremote.ScriptCallFunctionParameters
{
functionDeclaration: string;
awaitPromise: boolean;
target: ScriptTarget;
arguments?: ScriptLocalValue[];
resultOwnership?: ScriptResultOwnership;
serializationOptions?: ScriptSerializationOptions;
this?: ScriptLocalValue;
userActivation?: boolean;
}

scriptEvaluate​

WebDriver Bidi命令,用于发送命令方法"script.evaluate"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.scriptEvaluate(params)
参数​
名称类型详情
paramsremote.ScriptEvaluateParameters
{
expression: string;
target: ScriptTarget;
awaitPromise: boolean;
resultOwnership?: ScriptResultOwnership;
serializationOptions?: ScriptSerializationOptions;
userActivation?: boolean;
}
返回​
  • <Object> local.ScriptEvaluateResult: 命令返回值,具有以下接口:
    ;

scriptGetRealms​

WebDriver Bidi命令,用于发送命令方法"script.getRealms"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.scriptGetRealms(params)
参数​
名称类型详情
paramsremote.ScriptGetRealmsParameters
{
context?: BrowsingContextBrowsingContext;
type?: ScriptRealmType;
}
返回​
  • <Object> local.ScriptGetRealmsResult: 命令返回值,具有以下接口:
    {
    realms: ScriptRealmInfo[];
    }

scriptRemovePreloadScript​

WebDriver Bidi命令,用于发送命令方法"script.removePreloadScript"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.scriptRemovePreloadScript(params)
参数​
名称类型详情
paramsremote.ScriptRemovePreloadScriptParameters
{
script: ScriptPreloadScript;
}

storageGetCookies​

WebDriver Bidi命令,用于发送命令方法"storage.getCookies"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.storageGetCookies(params)
参数​
名称类型详情
paramsremote.StorageGetCookiesParameters
{
filter?: StorageCookieFilter;
partition?: StoragePartitionDescriptor;
}
返回​
  • <Object> local.StorageGetCookiesResult: 命令返回值,具有以下接口:
    {
    cookies: NetworkCookie[];
    partitionKey: StoragePartitionKey;
    }

storageSetCookie​

WebDriver Bidi命令,用于发送命令方法"storage.setCookie"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.storageSetCookie(params)
参数​
名称类型详情
paramsremote.StorageSetCookieParameters
{
cookie: StoragePartialCookie;
partition?: StoragePartitionDescriptor;
}
返回​
  • <Object> local.StorageSetCookieResult: 命令返回值,具有以下接口:
    {
    partitionKey: StoragePartitionKey;
    }

storageDeleteCookies​

WebDriver Bidi命令,用于发送命令方法"storage.deleteCookies"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.storageDeleteCookies(params)
参数​
名称类型详情
paramsremote.StorageDeleteCookiesParameters
{
filter?: StorageCookieFilter;
partition?: StoragePartitionDescriptor;
}
返回​
  • <Object> local.StorageDeleteCookiesResult: 命令返回值,具有以下接口:
    {
    partitionKey: StoragePartitionKey;
    }

inputPerformActions​

WebDriver Bidi命令,用于发送命令方法"input.performActions"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.inputPerformActions(params)
参数​
名称类型详情
paramsremote.InputPerformActionsParameters
{
context: BrowsingContextBrowsingContext;
actions: InputSourceActions[];
}

inputReleaseActions​

WebDriver Bidi命令,用于发送命令方法"input.releaseActions"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.inputReleaseActions(params)
参数​
名称类型详情
paramsremote.InputReleaseActionsParameters
{
context: BrowsingContextBrowsingContext;
}

inputSetFiles​

WebDriver Bidi命令,用于发送命令方法"input.setFiles"及其参数。

WebDriver Bidi协议命令。更多详情可以在官方协议文档中找到。

用法​
browser.inputSetFiles(params)
参数​
名称类型详情
paramsremote.InputSetFilesParameters
{
context: BrowsingContextBrowsingContext;
element: ScriptSharedReference;
files: string[];
}

Welcome! How can I help?

WebdriverIO AI Copilot