Run Keyword And Expect Error : behavior

Hi !

I’ve been trying to understand and have a better use of the mentioned keyword, and wonder if there are some hints or info on the way it works.

Idea is that I run in debug mode the test, which fails on a non found button. I get the error (copy it I mean), and put it in the keyword :

Run Keyword And Expect Error    copiedError    Click Element     mybutton

It took care of setting all the message, get the punctuation etc… But when running it fails :slightly_smiling_face: however in a wrong way as the error is not as expected.
I copy then the actual ‘aaa’ message in ‘Expected xxx but got aaa’, replace it but it doesn’t work better.

Finally I’m using this :

Run Keyword And Expect Error    REGEXP:Element with locator '.*mybutton.*' not found.*     Click Element     mybutton

Of course this is more flexible and would avoid maintenance if the my button full xpath evolves, but I’m really eager to understand the behavior.
Been looking in from lines 2230, but did not found my answer.


Hi Charlie,

Did your message “aaa” contain any of the glob wild card characters (* ? []) by any chance?

By default it is interpreted as a glob pattern with *, ? and [chars] as wildcards


1 Like

Damn ! Of course they do… All my xpath are variabilized in a POM to enhance maintenance, but the error gets real xpath content, so mainly something like //div[@id=‘myid’]

Thanks Dave :blush: I see now that all this time the brackets have been used as glob pattern…
That might help me in the future!


1 Like