appium: Setting driver.updateSettings({ snapshotMaxDepth: 60 }) doesn't have any effect

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Setting a custom snapshotMaxDepth doesn’t work

The problem was discovered after upgrading the Appium XCUITestDriver driver from 4.12.2 to 4.12.3 . Setting a custom snapshotMaxDepth works with driver version 4.12.2 but doesn’t seem to have any affect with 4.12.3 or any of the versions above that. From a quick check it seems the problem might have been introduced here: https://github.com/appium/WebDriverAgent/pull/638 https://github.com/appium/WebDriverAgent/compare/v4.10.9...v4.10.10

Expected Behavior

Elements nested deeper than 50 levels in the DOM can still be found by increasing the snapshotMaxDepth.

Minimal Reproducible Example

Using Appium 2.0.0-beta.52 and xcuitest@4.12.3

  1. Find an element that could only be found by increasing the snapshotMaxDepth
  2. Set a custom snapshotMaxDepth by calling the Webdriverio Appium command driver.updateSettings({ snapshotMaxDepth: 60 })
  3. Element can NOT be found

Using Appium 2.0.0-beta.52 and xcuitest@4.12.2

  1. Find an element that could only be found by increasing the snapshotMaxDepth
  2. Set a custom snapshotMaxDepth by calling the Webdriverio Appium command driver.updateSettings({ snapshotMaxDepth: 60 })
  3. Element CAN be found

Environment

  • appium version 2.0.0-beta.52
  • xcuitest@4.12.3
  • node version v19.1.0
  • iOS simulator -> iOS 15.4 , iOS16.1, iOS 16.2

Link to Appium Logs

https://gist.github.com/razvan-avi/028664cff16dec6f880302401f40268b

Futher Information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 36 (8 by maintainers)

Most upvoted comments

@hdesai-dave the fix in question is related to element lookup by Xpath, the page source flow does not go through this route.

Previously locating elements nested in a depth of 54 was not possible when increasing the snapshot max depth, however it is possible after this change (in combination of setting the snapshot max depth to 60).

I’ve increased the tree depth of my test app to 60 and tried to use the page source command to retrieve the elements tree and was only successful after limiting the snapshot max depth specifically to 62. It seems that any value larger than 62 (at least in my test application) causes the snapshot retrieval to fail in the testmanagerd side with a Too many nested arrays or dictionaries CoreFoundation error. Unfortunately we have no influence of that limit (this error originates from CoreFoundation, meaning this limit is from the OS level), so it looks like 62 is the maximum value testmanagerd can handle.

I’m testing an iOS app, I’m using this capabilitys on my Appium Inspector

{
  "appium:deviceName": "iPhone 14",
  "appium:platformName": "ios",
  "appium:platformVersion": "16.2",
  "appium:bundleId": "********",
  "appium:automationName": "XCUITest",
  "appium:settings[snapshotMaxDepth]": 70,
  "appium:settings[customSnapshotTimeout]": "50000"
}

I’m using Appium 2

Appium Inspector still loading and I don’t the app source

I want to get xpath element with Appium inspector

Any help please

Depth must be below 63. 62 is max

@Dor-bl sure, just open a new issue with all the relevant logs

When I use depth 62, I still have element not visible, I can’t get them? any solution please?

Yes, it probably means it is too deeply nested

@mykola-mokhnach, you cannot really set “session settings” in any session with xcuitest 4.12.3 or above. The thing that changed from 4.12.2 to 4.12.3 is also upgrading appium-webdriveragent to 4.10.10 image

This new version contains some changes that explicitly touched the “session settings” https://github.com/appium/WebDriverAgent/pull/629 Could it be, now that we are resetting the session-specific settings on startup we are also interfering with actually setting them?

Some additional findings: Initializing a setting via capabilities doesn’t work 'appium:settings[snapshotMaxDepth]': 500

Using webdriverio command doesn’t work: driver.updateSettings({ snapshotMaxDepth: 60 })

both options were working previously. Interestingly enough I can see the settings being set using driver.getSettings() they just don’t have any effect.

[0-0] 2023-01-23T16:25:50.588Z INFO webdriver: COMMAND getSettings()
[0-0] 2023-01-23T16:25:50.589Z INFO webdriver: [GET] http://localhost:4723/session/d3223d57-f622-40d6-a467-19a6bbf78ab4/appium/settings
[0-0] 2023-01-23T16:25:50.591Z INFO webdriver: RESULT {
[0-0]   nativeWebTap: false,
[0-0]   nativeWebTapStrict: false,
[0-0]   useJSONSource: false,
[0-0]   shouldUseCompactResponses: true,
[0-0]   elementResponseAttributes: 'type,label',
[0-0]   mjpegServerScreenshotQuality: 25,
[0-0]   mjpegServerFramerate: 10,
[0-0]   screenshotQuality: 1,
[0-0]   mjpegScalingFactor: 100,
[0-0]   reduceMotion: null,
[0-0]   snapshotMaxDepth: 60,
[0-0]   ignoreUnimportantViews: true
[0-0] }

Also using the Appium inspector I can still properly set the snapshotMaxDepth successfully, which allows me to identify +50 nested elements like so: "appium:settings[snapshotMaxDepth]": "60",

Not sure if this helps in any way, just wanted to add some additional findings. Let me know if I can help out investigating this further. thanks!