How to test UMG UI properly?

After reading the Automation Driver (Official Docs) - I’m trying to do a super simple thing: basically load my menu level and test my UI - click some buttons, navigate some areas, etc.

I have a simple UMG menu, nothing fancy. Problem is: I can’t quite figure out how to mark the UMG elements so that the driver sees them.

My code:

...
void MainMenuNavigationSpec::Define()
{
    BeforeEach([this]()
    {
        AutomationOpenMap("/Game/L_MainMenu");
        World = GetWorld();

        IAutomationDriverModule::Get().Enable();
        Driver = IAutomationDriverModule::Get().CreateDriver();
    });

    Describe("Main Menu Navigation", [this]()
    {
        It("should navigate to the Settings menu when clicking the Settings button", EAsyncExecution::ThreadPool, [this]()
        {
            FPlatformProcess::Sleep(1.0f); 
            FDriverElementRef Element = Driver->FindElement(By::Id("WhatDoIWriteHere?"));
            TestTrue("Button_Settings", Element->Exists());
...

If I play the spec in session frontend - all good, I see my menu, but I can’t find any element. Docs say I need to add some kind of metadata using something like ..AddMetaData(FDriverMetaData::Id("SignUpFormFirstNameField")) - but UMG doesn’t give me direct access to Slate elements, so I guess I can’t use this?

Or is Automation Driver not meant to be used with Slate at all? (Looks like it - all examples are slate-only).

I feel lost. Any advise would be very valuable, as I find the docs / information on the topic very scarse.

1 Like