Problem parsing multi-line UiAutomator code. InvalidSelectorException: Could not parse selector expression: UiScrollable has no suitable constructor with arguments
coryffaeus opened this issue · 2 comments
coryffaeus commented
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:
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!
jlipps commented
This may be expected. Any reason you don't want to just strip newlines on your end?
coryffaeus commented
If that's the expected behaviour, then no particular reason not to, of course. Thank you!