Skip to content

Commit

Permalink
add useNewJSONSource support to get new source
Browse files Browse the repository at this point in the history
  • Loading branch information
vinaykumar0339 committed Dec 21, 2024
1 parent 0be69bc commit bf5e5be
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/commands/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 3 additions & 0 deletions lib/desired-caps.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ const desiredCapConstraints = /** @type {const} */ ({
useJSONSource: {
isBoolean: true,
},
useNewJSONSource: {
isBoolean: true,
},
enforceFreshSimulatorCreation: {
isBoolean: true,
},
Expand Down
5 changes: 5 additions & 0 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const DEFAULT_SETTINGS = {
nativeWebTap: false,
nativeWebTapStrict: false,
useJSONSource: false,
useNewJSONSource: true,
webScreenshotMode: 'native',
shouldUseCompactResponses: true,
elementResponseAttributes: 'type,label',
Expand Down Expand Up @@ -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});
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"npm": ">=8"
},
"appium": {
"driverName": "xcuitest",
"automationName": "XCUITest",
"driverName": "xcuitestdriver",
"automationName": "XCUITestDriver",
"platformNames": [
"iOS",
"tvOS"
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit bf5e5be

Please sign in to comment.