Automated Tapping on Dropdown Items in Telerik Controls for UI for .NET MAUI
Environment
| Version | Product | Author |
|---|---|---|
| 12.0.0 | Telerik UI for .NET MAUI ComboBox and AutoComplete | Dobrinka Yordanova |
Description
I encountered issues performing automated UI testing with Appium for Telerik UI for .NET MAUI controls that use dropdowns, such as ComboBox and AutoComplete. The dropdown or suggestion view in these controls uses the RadPopup control, which is not visible in UIAutomator, affecting Appium testing on Android.
Cause
The issue arises because the RadPopup control is not visible in the UI tree due to a problem with UIAutomator, as noted in the related Google issue tracker. Additionally, making the popup focusable is not a viable solution as it interferes with the functionality of the dropdown controls.
Solution
To automate tapping on dropdown items, use the following workaround:
- Calculate the coordinates for tapping based on the default height of a dropdown item, which is
32pixels. - Use Appium's coordinate-based tap functionality to simulate tapping on the desired item.
Below is an example approach for automation using internal methods and Appium:
case FindBy.AutomatiomationId:
appiumStrategy = MobileBy.AccessibilityId(locator); break;
case FindBy.XPath:
appiumStrategy = By.XPath(locator); break;
case FindBy.ClassName:
appiumStrategy = By.ClassName(locator); break;
case FindBy.Name:
appiumStrategy = By.Name(locator); break;
AutomationId Limitations
Be aware of the following issues with AutomationId:
- Android: AutomationId does not work (GitHub issue).
- Windows: AutomationId does not work for
ContentView,Layouts, and controls inheriting them (GitHub issue).
Workaround for AutomationId
Use the SetAutomationIds() method from the sample application provided by Telerik to address AutomationId issues.