Robot Framework is not interact with Snackbar element

I am using the Robot Framework along with the Browser library to automate a website that displays success or error messages using Snackbar. Despite this element being visible on the screen and inspectable, the framework seems unable to identify or interact with it during execution. I consistently receive a message stating that the element is not visible and that I should increase the timeout, even though when I run it in headed mode, I can see the element appear and disappear, and the framework continues waiting for it.

Here is the element locator:

<simple-snack-bar class=“mat-simple-snackbar ng-star-inserted”>
<span class=“mat-simple-snack-bar-content”>Your third-party has been created

And here is my keyword:

Validate that the message is displayed
[Arguments]                          ${Message}
Get Text                             ${Lbl_SnackBar}   ==   ${Message}


  • ${Message} is Your third-party has been created
  • ${Lbl_SnackBar} is css=span[class=‘mat-simple-snack-bar-content’]

Any idea what am I doing wrong?

Hi Joseilton,

The problem might be

"Your third-party has been created"

is not the same as

"Your third-party has been created

The new line character(s) might be causing you grief?

First try without the validation, confirm you get the text message

Get Text                             ${Lbl_SnackBar}

Then try with the contains operator instead of the exactly equals operator

Get Text                             ${Lbl_SnackBar}   *=   ${Message}

Hopefully that solves your issue,


Hi Dave,

Thank you very much for your response, but I don’t believe that’s the issue, as in that case, the message would be something like “Expected A, but you received B.”

Anyway, I tested it here, and the problem persists. Please take a look at the error I’m receiving. I even used the Get Element State keyword, and the return is that the element is detached.

Error: locator.elementHandle: Timeout 20000ms exceeded.
Call log:

  • waiting for locator(‘span[class='mat-simple-snack-bar-content']’)

O que retorna da Get Element State

KEYWORD Browser . Get Element States ${Lbl_SnackBar}, validate, visible

Documentation: Get the active states from the element found by selector.
Tags: Assertion, Getter, PageContent
Start / End / Elapsed: 20240112 09:05:41.800 / 20240112 09:05:42.065 / 00:00:00.265

09:05:42.065 INFO States are: [‘detached’]

So even though I can see the element on the screen at runtime, it seems that it is not present in the DOM, and maybe that’s why it’s not being located by the framework, and I can’t interact with it. I don’t know what to do in this case.

Hi Joseilton,

Does it popup on the screen and then disappear after a few hundred milliseconds? perhaps it’s not staying on the screen long enough and that’s causing the issue? That would explain the detached state.

Initially I was thinking maybe there are other classes and your matching a single class in your css selector (I’m not so familiar with css selectors so not sure if that might be an issue) but then I see the detached state from Get Element States meaning that the selector is able to find the element.

I’d be surprised if it was an issue of the element disappearing before the Get Text keyword can finish interacting with it as robot framework keywords normally only take a few ms to execute, but I’ve also seen some pretty weird stuff over the years, so not discounting anything.

Also I wonder if you’d have better luck with a different selector type (e.g. xpath), that might be worth a try?


Hi Joseilton,
Have you checked the xpath in your browser before to use it in in RF? For me it’s seems missing an ‘@’.
Try with span[@class=‘mat-simple-snack-bar-content’]

Hope it’s helpfull

Hi Stephan,

I’m using css selector instead xpath, so in this case there’s no need to put the @ before the class, but I’ll follow the Dave sugestion and will try to use xpath instead css on this particular selector to see.

Thank you very much for your reply.