From 6278904eb6ae2e6014d84bf330cda46631e95699 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Tue, 18 Apr 2023 08:00:41 +0000 Subject: [PATCH] feat: add mobile:webInspector to send webinspector command --- lib/commands/web.js | 21 ++++++++++++++++++++- lib/driver.js | 1 + lib/execute-method-map.ts | 7 +++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/commands/web.js b/lib/commands/web.js index 6ee1fb505..ec7ac93bb 100644 --- a/lib/commands/web.js +++ b/lib/commands/web.js @@ -869,6 +869,26 @@ const extensions = { // @ts-expect-error - do not assign arbitrary properties to `this.opts` await this.opts.device.updateSafariSettings(preferences); }, + + /** + * Send Web Inspector command to the remote debugger. + * https://github.com/appium/appium-remote-debugger/blob/717a6310dba7ccf14db8aeef28b8eac3d7f6abf9/lib/protocol/index.js + * + * @param {string} method A command method name. e.g. Page.reload + * @param {object} args Arguments for the method. Please check what arguments are available in + * https://github.com/appium/appium-remote-debugger/blob/717a6310dba7ccf14db8aeef28b8eac3d7f6abf9/lib/protocol/index.js + */ + async mobileWebInspector(method, args) { + if (this.remote) { + return; + } + + await this.remote.rpcClient.send(method, { + args, + appIdKey: this.remote.appIdKey, + pageIdKey: this.remote.pageIdKey, + }); + }, }; export default {...helpers, ...extensions, ...commands}; @@ -881,4 +901,3 @@ export default {...helpers, ...extensions, ...commands}; * @template {string} [S=string] * @typedef {import('@appium/types').Element} Element */ - diff --git a/lib/driver.js b/lib/driver.js index f57bbcedf..469681832 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -2159,6 +2159,7 @@ class XCUITestDriver extends BaseDriver { mobileWebNav = commands.webExtensions.mobileWebNav; mobileUpdateSafariPreferences = commands.webExtensions.mobileUpdateSafariPreferences; clickCoords = commands.webExtensions.clickCoords; + mobileWebInspector = commands.webExtensions.mobileWebInspector; /*--------+ | XCTEST | diff --git a/lib/execute-method-map.ts b/lib/execute-method-map.ts index e36ecc5ef..f9796492c 100644 --- a/lib/execute-method-map.ts +++ b/lib/execute-method-map.ts @@ -461,4 +461,11 @@ export const executeMethodMap = { 'mobile: stopAudioRecording': { command: 'stopAudioRecording', }, + 'mobile: webInspector': { + command: 'mobileWebInspector', + params: { + required: ['method'], + optional: ['args'] + } + } } as const satisfies ExecuteMethodMap;