From bf5e5bed952e9a3c22a46e8607077b9d73c72424 Mon Sep 17 00:00:00 2001 From: vinaykumar0339 <66993050+vinaykumar0339@users.noreply.github.com> Date: Sat, 21 Dec 2024 16:29:41 +0530 Subject: [PATCH] add useNewJSONSource support to get new source --- lib/commands/source.js | 8 ++++++-- lib/commands/types.ts | 2 +- lib/desired-caps.js | 3 +++ lib/driver.js | 5 +++++ package.json | 6 +++--- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/commands/source.js b/lib/commands/source.js index 4d3df6916..bae6aeea6 100644 --- a/lib/commands/source.js +++ b/lib/commands/source.js @@ -15,10 +15,14 @@ const commands = { const { pageSourceExcludedAttributes: excludedAttributes, - useJSONSource + useJSONSource, + useNewJSONSource, } = await this.settings.getSettings(); const hasExcludedAttributes = _.isString(excludedAttributes) && !_.isEmpty(excludedAttributes); - if (useJSONSource) { + if (useNewJSONSource) { + return await this.mobileGetSource('newJson'); + } + else if (useJSONSource) { const srcTree = await this.mobileGetSource('json', hasExcludedAttributes ? excludedAttributes : undefined); return getSourceXml(getTreeForXML(srcTree)); } diff --git a/lib/commands/types.ts b/lib/commands/types.ts index acb255596..6a5860a4a 100644 --- a/lib/commands/types.ts +++ b/lib/commands/types.ts @@ -217,7 +217,7 @@ export interface View { * one to fetch. * - `json`: Similar to `xml`, but the tree hierarchy is represented as JSON elements. */ -export type SourceFormat = 'xml' | 'json' | 'description'; +export type SourceFormat = 'xml' | 'json' | 'description' | 'newJson'; /** @deprecated */ export type AppInstallStrategy = 'serial' | 'parallel' | 'ios-deploy'; diff --git a/lib/desired-caps.js b/lib/desired-caps.js index 5c5666156..46ee1d9e7 100644 --- a/lib/desired-caps.js +++ b/lib/desired-caps.js @@ -242,6 +242,9 @@ const desiredCapConstraints = /** @type {const} */ ({ useJSONSource: { isBoolean: true, }, + useNewJSONSource: { + isBoolean: true, + }, enforceFreshSimulatorCreation: { isBoolean: true, }, diff --git a/lib/driver.js b/lib/driver.js index b1a632771..0f7ead53e 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -86,6 +86,7 @@ const DEFAULT_SETTINGS = { nativeWebTap: false, nativeWebTapStrict: false, useJSONSource: false, + useNewJSONSource: true, webScreenshotMode: 'native', shouldUseCompactResponses: true, elementResponseAttributes: 'type,label', @@ -438,6 +439,10 @@ export class XCUITestDriver extends BaseDriver { if (_.has(this.opts, 'nativeWebTapStrict')) { await this.updateSettings({nativeWebTapStrict: this.opts.nativeWebTapStrict}); } + // ensure we track useNewJSONSource capability as a setting as well + if (_.has(this.opts, 'useNewJSONSource')) { + await this.updateSettings({useNewJSONSource: this.opts.useNewJSONSource}); + } // ensure we track useJSONSource capability as a setting as well if (_.has(this.opts, 'useJSONSource')) { await this.updateSettings({useJSONSource: this.opts.useJSONSource}); diff --git a/package.json b/package.json index f9eea4dbd..ba7bc63dd 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "npm": ">=8" }, "appium": { - "driverName": "xcuitest", - "automationName": "XCUITest", + "driverName": "xcuitestdriver", + "automationName": "XCUITestDriver", "platformNames": [ "iOS", "tvOS" @@ -81,7 +81,7 @@ "appium-ios-device": "^2.7.23", "appium-ios-simulator": "^6.1.7", "appium-remote-debugger": "^12.1.1", - "appium-webdriveragent": "^8.12.0", + "appium-webdriveragent": "file:../WebDriverAgent", "appium-xcode": "^5.1.4", "async-lock": "^1.4.0", "asyncbox": "^3.0.0",