# How do I correctly use the Automation Driver and Automation Spec for UI testing?

**URL:** <https://forums.unrealengine.com/t/how-do-i-correctly-use-the-automation-driver-and-automation-spec-for-ui-testing/464708>\
**Category:** UI\
**Tags:** testing, automated-testing, unreal-engine, UI, question\
**Created:** [May 5, 2020, 5:28pm UTC](https://forums.unrealengine.com/t/how-do-i-correctly-use-the-automation-driver-and-automation-spec-for-ui-testing/464708 "2020-05-05T17:28:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RickMortis2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RickMortis2](https://forums.unrealengine.com/u/RickMortis2)\
**Post date:** [May 5, 2020, 5:28pm UTC](https://forums.unrealengine.com/t/how-do-i-correctly-use-the-automation-driver-and-automation-spec-for-ui-testing/464708/1 "2020-05-05T17:28:43Z")

</div>

Hi all,

I writing a UI test. It’s purpose is to test that all elements of my ability bar are clickable. To give the context:  
I have an ability bar widget which is just a container for Ability item widgets.

Having looked at the documentation for Automation Driver and Automation Spec I set up my tests to find those elements and also test if they can be focused. These tests are succesfull.

However, when I try to MoveToElement and Click, it locates the element however, I get an error saying that the element is not under the cursor. It seems that the game never receives focus (cursor texture stays as the default Windows texture) and because of that, the cursor never moves to my element. IsHovered also fails the test

Code snippet:

```
FDriverElementRef a = Driver->FindElement(By::Id(Tag));
FDriverSequenceRef Sequence = Driver->CreateSequence();
Sequence->Actions()
.Wait(Until::ElementExists(a, FWaitTimeout::InSeconds(3)))
.MoveToElement(a)
.Click(a);

TEST_TRUE(Sequence->Perform());

```

And here is another point to take into consideration. I am then manually checking the cursor position through the Driver, and my widget’s position and they **match** , which to me doesnt make sense. Here is the code for that too:

```
int32 x = Driver->GetCursorPosition().X;
int32 y = Driver->GetCursorPosition().Y;
FText FX = FText::AsNumber(x);
FText FY = FText::AsNumber(y);

int32 ax = SAbilityItem->GetAbsolutePosition().X;
int32 ay = SAbilityItem->GetAbsolutePosition().Y;
FText AX = FText::AsNumber(x);
FText AY = FText::AsNumber(y);

UE_LOG(MyLog, Log, TEXT("Cursor position is %s x, %s y and ability item absolute position is %s x, %s y"), *FX.ToString(), *FY.ToString(), *AX.ToString(), *AY.ToString());

```

Any help or suggestions will be greatly appreciated.

Thank you in advance,

Kind regards,  
Paris

---

<div class="post-metadata">

**Author:** ![RickMortis2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RickMortis2](https://forums.unrealengine.com/u/RickMortis2)\
**Post date:** [May 14, 2020, 9:28am UTC](https://forums.unrealengine.com/t/how-do-i-correctly-use-the-automation-driver-and-automation-spec-for-ui-testing/464708/2 "2020-05-14T09:28:20Z")

</div>

Update: On 4.25 the main issue is fixed and now the Automation Driver successfully takes control and simulates the input. There is still an issue, where the tests fail the first time. The error is the following:

Failed to load cursor ‘…/…/…/Hannibal/Content/Slate/Cursor/DefaultCursor’ [C:\gamedev\hannibal\main\ue4\Engine\Source\Runtime\Engine\Private\GameViewportClient.cpp(3776)]

It seems the first time it’s trying to load a Hardware cursor through the AutomatedApplication::CreateCursorFromRGBABuffer which is not implemented and returns a null which then gives the above error.

It appears to be an issue of loading the test level/game after the test has started whereas to my understanding it should be the other way around.

So to bypass this issue as a temp solution, run the test once, keep the PIE window open (should stay open on its own), run the test again and it works.

---

<div class="post-metadata">

**Author:** ![regionbase](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@regionbase](https://forums.unrealengine.com/u/regionbase)\
**Post date:** [August 5, 2020, 9:08am UTC](https://forums.unrealengine.com/t/how-do-i-correctly-use-the-automation-driver-and-automation-spec-for-ui-testing/464708/3 "2020-08-05T09:08:33Z")

</div>

Hi, I’m a novice on Automation Driver and ue4. I am confused on how to create a c++ file to write the test case. I create use the engine editor but it build failed and shows could not found the include file. I just write these lines:

#include “AutomationDriverCommon.h”  
#include “AutomationDriverTypeDefs.h”

BEGIN\_DEFINE\_SPEC(FAutomationDriver2Spec,  
“System.Automation.Driver2”,  
EAutomationTestFlags::ProductFilter | EAutomationTestFlags::ApplicationContextMask)  
FAutomationDriverPtr Driver;  
END\_DEFINE\_SPEC(FAutomationDriver2Spec)  
void FAutomationDriver2Spec::Define()  
{  
IAutomationDriverModule::Get().Enable();  
IAutomationDriverModule::Get().Disable();  
}

Could you give me some suggestions? Thank you!

---

<div class="post-metadata">

**Author:** ![Vityoki](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vityoki](https://forums.unrealengine.com/u/Vityoki)\
**Post date:** [December 18, 2020, 3:49pm UTC](https://forums.unrealengine.com/t/how-do-i-correctly-use-the-automation-driver-and-automation-spec-for-ui-testing/464708/4 "2020-12-18T15:49:23Z")

</div>

Check your ini config.  
/Script/Engine.UserInterfaceSettings  
HardwareCursors=((Default, (… problem should be here

---

<div class="post-metadata">

**Author:** ![ZRogers-US](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ZRogers-US](https://forums.unrealengine.com/u/ZRogers-US)\
**Post date:** [July 18, 2024, 9:59am UTC](https://forums.unrealengine.com/t/how-do-i-correctly-use-the-automation-driver-and-automation-spec-for-ui-testing/464708/5 "2024-07-18T09:59:48Z")

</div>

> [@RickMortis2](#):
>
> `Tag`

Hi RickMortis2 i know this was a few years back but I was wondering if you where using the automation driver with UMG widgets or had you originally created them from slate? if it was UMG widgets how were you finding the elements? i’ve managed to implement the automation driver with slate but when ever i try with UMG i cant find a way to tag them with the FDriverMetaData ID.

---

<div class="post-metadata">

**Author:** ![Manny\_Jerome](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Manny\_Jerome](https://forums.unrealengine.com/u/Manny_Jerome)\
**Post date:** [July 9, 2025, 2:41pm UTC](https://forums.unrealengine.com/t/how-do-i-correctly-use-the-automation-driver-and-automation-spec-for-ui-testing/464708/6 "2025-07-09T14:41:36Z")

</div>

Hey there, to find the UMG element you have to set its metadata, but the MetaData can only be set as a slate component in C++. So I found the elements by creating a blueprint helper function that adds a MetaData to the UMG element as a generic slate element in C++ and calling the helper function in the Widget BP OnConstruct
