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
<!---->
</simple-snack-bar>
And here is my keyword:
Validate that the message is displayed
[Arguments] ${Message}
Get Text ${Lbl_SnackBar} == ${Message}
Where:
${Message} is Your third-party has been created
${Lbl_SnackBar} is css=span[class=‘mat-simple-snack-bar-content’]
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.
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.
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’]
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.