Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the description of setting API snapshotMaxDepth #629

Merged

Conversation

yoshitaka-ogata
Copy link
Contributor

Add the description of setting API snapshotMaxDepth.
Based on appium/appium-uiautomator2-server#517 (comment)

@KazuCocoa KazuCocoa changed the title docs: add the description of setting API snapshotMaxDepth feat: add the description of setting API snapshotMaxDepth Jun 20, 2023
README.md Outdated
@@ -289,6 +289,7 @@ enforceXPath1 | boolean | Since UiAutomator2 driver version `4.25.0` XPath2 is s
limitXPathContextScope | boolean | Due to historical reasons UiAutomator2 driver limits scopes of element context-based searches to the parent element. This means a request like `findElement(By.xpath, "//root").findElement(By.xpath, "./..")` would always fail, because the driver only collects descendants of the `root` element for the destination XML source. The `limitXPathContextScope` setting being set to `false` changes that default behavior, so the collected page source includes the whole page source XML where `root` node is set as the search context. With that setting disabled the search query above should not fail anymore. Although, you must still be careful while building XPath requests for context-based searches with the `limitXPathContextScope` setting set to `false`. A request like `findElement(By.xpath, "//root").findElement(By.xpath, "//element")` would ignore the current context and search for `element` trough the whole page source. Use `.` notation to correct that behavior and only find `element` nodes which are descendants of the `root` node: `findElement(By.xpath, "//root").findElement(By.xpath, ".//element")`.
disableIdLocatorAutocompletion | boolean | According to internal Android standards it is expected that each resource identifier is prefixed with `<packageName>:id/` string. This should guarantee uniqueness of each identifier. Although some application development frameworks ignore this rule and don't add such prefix automatically or, rather, let it up to the developer to decide how to represent their application identifiers. For example, [testTag modifier attribute in the Jetpack Compose](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/package-summary#(androidx.compose.ui.Modifier).testTag(kotlin.String)) with [testTagsAsResourceId](https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/package-summary#(androidx.compose.ui.semantics.SemanticsPropertyReceiver).testTagsAsResourceId()) allows developers to set an arbitrary string without the prefix rule. [Interoperability with UiAutomator](https://developer.android.com/jetpack/compose/testing) also explains how to set it. By default UIA2 driver adds the above prefixes automatically to all resource id locators if they are not prefixed, but in case of such "special" apps this feature might be disabled by assigning the setting to `true`.
includeExtrasInPageSource | boolean | Whether to include `extras` element attribute in the XML page source result. Then, XPath locator can find the element by the extras. Its value consists of combined [getExtras](https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo#getExtras()) as `keys=value` pair separated by a semicolon (`;`), thus you may need to find the element with partial matching like `contains` e.g. `driver.find_element :xpath, '//*[contains(@extras, "AccessibilityNodeInfo.roleDescription=")]'`. The value could be huge if elements in the XML page source have large `extras`. It could affect the performance of XML page source generation.
snapshotMaxDepth | int | The number of maximum depth for snapshot. The default value is `70`. This number should be in range [1, 500]. A part of elements source tree might be lost if the value was small. Also, StackOverflow might be caused if the value was large (Issues [1](https://github.com/appium/appium/issues/12545), [2](https://github.com/appium/appium/issues/12892)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you address the available driver version? The version will be 2.27.0 as feat

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review!
I have a question. I added a setting API snapshotMaxDepth in appium-uiautomator2-server. I think a setting API does not depend on the driver version, I'm sorry if I misunderstand.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct for the UIA2 server, but users use UIA2 driver to manage UIA2 server as well. It means users who install a new pushed driver version with 5.12.0 UIA2 server version can use this snapshotMaxDepth. So to expose this snapshotMaxDepth for users via UIA2 server, they need a new UIA2 driver pushed by this PR merge

Copy link
Contributor

@mykola-mokhnach mykola-mokhnach Jun 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...for the source tree snapshot...

...part of the elements source tree...

...if the value is too low...

...if the value is too high (issues 12545, 12892)...

...Also, StackOverflowError might...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I added the available version and updated some commented points. c5f5525

@mykola-mokhnach mykola-mokhnach merged commit c74ad63 into appium:master Jun 21, 2023
github-actions bot pushed a commit that referenced this pull request Jun 21, 2023
## [2.27.0](v2.26.3...v2.27.0) (2023-06-21)

### Features

* add the description of setting API snapshotMaxDepth ([#629](#629)) ([c74ad63](c74ad63))
@github-actions
Copy link

🎉 This PR is included in version 2.27.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants