Robot Framework - How to refer a button ID which changes frequently?

722 views Asked by At

I have a sign in page, in which the id of the sign-in button changes. The id can either one of the two.

id = signin
or
id = signin_cache1

The id is assigned in Java based on the math.random() function. The statement is,

num = (int)(math.random() * 100)
if num < 50 id=signin
if num > 50 id=signin_cache1

My robot framework with selenium2library script fails, if the id is different from the one I coded in the script. Is there a way in robot framework to refer both ids so that my script never fails?

1

There are 1 answers

1
Hubert Grzeskowiak On

How about css=#signin, #signin_cache1 or css=[id^="signin"]?

The first is a selector that matches all elements with id "signin" and all elements with id "signin_cache1". The second selector looks up all elements with an id attribute which starts with "signin".

(I'm only guessing since I only know Selenium 2 / WebDriver and haven't worked with the Robot Framework yet. The documentation for it seems to be very fragmented.)