java-client icon indicating copy to clipboard operation
java-client copied to clipboard

multiple locators not work for @AndroidFindAll

Open ganjarpanji opened this issue 4 years ago • 3 comments

@AndroidFindAll(value = [AndroidBy(id = "button_tooltip", priority = 1), AndroidBy(id = "text_view_tooltip_ok", priority = 2)]) i defined element as above annotation, but when the ui displayed the second priority element, the driver not able to found it.

ganjarpanji avatar Jan 11 '21 07:01 ganjarpanji

Java code stuff? Please attach the appium server log to see the request.

KazuCocoa avatar Jan 11 '21 08:01 KazuCocoa

Actually I had a similar problem, in my case I was using Kotlin. My previous code:

@iOSXCUITFindAll(value = [iOSXCUITBy(accessibility = "accessabilityId")])
@AndroidFindAll(value = [AndroidBy(id = "id")])
lateinit var items: List<MobileElement>

I received error that lateinit var was not initialized. I looked into appium but the findElement request were all 200, and the element was found. I found out that the problem was that List that is used in Kotlin is not being parsed correctly, as it's a part of package kotlin.collections which is immutable 🤦 . I had to use MutableList instead and everything worked fine

@iOSXCUITFindAll(value = [iOSXCUITBy(accessibility = "accessabilityId")])
@AndroidFindAll(value = [AndroidBy(id = "id")])
lateinit var items: MutableList<MobileElement>

piotrgomola avatar Jan 29 '21 15:01 piotrgomola

@piotrgomola AFAIK you could try using ArrayList on kotlin, that should solve the issue.

ganjarpanji avatar Feb 01 '21 02:02 ganjarpanji