# 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](https://www.telerik.com/blogs/author/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](https://www.telerik.com/maui-ui/documentation/controls/combobox/overview) and [AutoComplete](https://www.telerik.com/maui-ui/documentation/controls/autocomplete/overview). 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](https://issuetracker.google.com/issues/37017411?pli=1). 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:

1. Calculate the coordinates for tapping based on the default height of a dropdown item, which is `32` pixels.
2. 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:

```csharp
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](https://github.com/dotnet/maui/issues/8277)).
* **Windows**: AutomationId does not work for `ContentView`, `Layouts`, and controls inheriting them ([GitHub issue](https://github.com/dotnet/maui/issues/4715)).

### Workaround for AutomationId

Use the `SetAutomationIds()` method from the [sample application](https://github.com/telerik/maui-samples/blob/main/Samples/AppUtils/Services/Testing/TestingExtensions.cs) provided by Telerik to address AutomationId issues.

## See Also

* [Google UIAutomator Issue](https://issuetracker.google.com/issues/37017411?pli=1)
* [AutomationId Issue on Android](https://github.com/dotnet/maui/issues/8277)
* [AutomationId Issue on Windows](https://github.com/dotnet/maui/issues/4715)
* [Sample Application for MAUI](https://github.com/telerik/maui-samples/blob/main/Samples/AppUtils/Services/Testing/TestingExtensions.cs)
