MaxRussell
MaxRussell

Reputation: 651

Compound class selector in RobotFramework with selenium

Trying to check the on screen state of an element which changes from :

class="slide-out-div contrastBoxDark closed"

to

class="slide-out-div contrastBoxDark"

however using

Page Should Contain Element    class:slide-out-div.contrastBoxDark

returns

InvalidSelectorException: Message: invalid selector: Compound class names not permitted

if the compound class name isn't permitted, what is a suitable locator and attribute here? Tried this, but it doesn't locate:

css:slide-out-div.contrastBoxDark

Upvotes: 2

Views: 6166

Answers (2)

Andersson
Andersson

Reputation: 52675

You cannot use more than 1 class name with search by class. In case you want to find element by more than 1 class name, try CSS selector:

For "opened"

css:[class="slide-out-div contrastBoxDark"]
css:.slide-out-div.contrastBoxDark:not(.closed)

For "closed"

css:[class="slide-out-div contrastBoxDark closed"]

Note that css:.slide-out-div.contrastBoxDark will match both "closed" and "opened" elements...

Also note that your CSS selector css:slide-out-div.contrastBoxDark will not work as it intend to match something like <slide-out-div class="contrastBoxDark">...</slide-out-div> as you forgot the dot before the first class name

Upvotes: 2

Murthi
Murthi

Reputation: 5347

You are missing .(dot) before the class slide-out-div in css selector. please try the following,

css:.slide-out-div.contrastBoxDark

Upvotes: 3

Related Questions