Appium UiAutomator/UiObject2-based server for Android UI automation. This module is used by appium-uiautomator2-driver component
Apache License 2.0
319
stars
227
forks
source link
Problem parsing multi-line UiAutomator code. InvalidSelectorException: Could not parse selector expression: UiScrollable has no suitable constructor with arguments #628
The code is written in Kotlin like the following, with the intent of using multiline input for better readability:
driver.findElement(
AppiumBy.androidUIAutomator(
"""
new UiScrollable(
new UiSelector()
.scrollable(true)
.instance(0)
).scrollIntoView(
new UiSelector()
.text("Frequently asked questions")
.instance(0)
);
""".trimIndent()
)
)
which produces the following exception:
Exception in thread "main" org.openqa.selenium.InvalidSelectorException: Could not parse selector expression `new UiScrollable(
new UiSelector()
.scrollable(true)
.instance(0)
).scrollIntoView(
new UiSelector().text("Frequently asked questions").instance(0)
)`: UiScrollable has no suitable constructor with arguments [new UiSelector()
.scrollable(true)
.instance(0)]
If the code is written in a single line, e.g.:
new UiScrollable(new UiSelector().scrollable(true).instance(0))
the exception is gone.
There was a similar issue already, so I thought I'd add another one. Thanks in advance!
Appium server: 2.5.1 Automation driver: uiautomator2@3.0.1 (automationName 'UiAutomator2') Appium client: io.appium:java-client:9.2.2 Env: MacOS Sonoma 14.4.1, Android emulator Pixel 3a API34 extension level 7 arm64-v8a
The code is written in Kotlin like the following, with the intent of using multiline input for better readability:
which produces the following exception:
If the code is written in a single line, e.g.:
the exception is gone.
There was a similar issue already, so I thought I'd add another one. Thanks in advance!