Accessibility in Xamarin Chat (SfChat)

13 May 20211 minute to read

SfChat support built-in AutomationId for all their inner elements. These AutomationId values allow the automation framework to find and interact with the inner elements when the test scripts are run. A unique AutomationId is maintained for each inner element by prefixing the control’s AutomationId with the inner element’s Id.

AutomationId for Chat elements

The below table illustrates the predefined automation values set internally which can be used to identify the Chat elements.

Element Value
Message editor "MessageEditor"
Send button "SendMessage"

The following screenshot illustrates the AutomationId values of the inner elements of SfChat.

Automation Id format for Chat inner element

The following code snippet demonstrates how to set the AutomationId to chat.

<sfChat:SfChat x:Name="sfChat"
                Messages="{Binding Messages}"
                CurrentUser="{Binding CurrentUser}" 
SfChat sfChat = new SfChat();
GettingStartedViewModel viewModel = new GettingStartedViewModel();
sfChat.Messages = viewModel.Messages;
sfChat.CurrentUser = viewModel.CurrentUser;
sfChat.ShowTypingIndicator = true;
sfChat.AutomationId = "SyncfusionChat";

Refer to the following code snippet to access the inner elements of chat from the automation script.

[Description("SfChat Automation Id")]
public void SfChat_AutomationId()
   // To tap the Message editor in the message input area
   App.Tap("SyncfusionChat MessageEditor");

   // To tap Send button in the message input area
   App.Tap("SyncfusionChat SendMessage");