Certification level II - can't get the locator for the random error message to work

Hi,
I’m working on certification level 2.
I can’t get the locator for the random error message to work.

I still having hard time understanding locators. I try to use class as locator, but it doesn’t seem to work.

${ErrorMessage}=    Does Page Contain Element    class:.alert-danger
IF    ${ErrorMessage}    Click Button    id:order

I tried class:alert alert-danger, class:alert-danger, class:div.alert.alert-danger, etc
but none if them works

The solution for the random error message is here:

2 Likes