TestProject Forum
Powered by leading experts in the test automation community

Selenium find element that has multiple class names

I have an element with 2 classes which I need to find with selenium

<div class="container pageContainer">
</div>

I can’t find it with by.classname(“container pageContainer”) since it does not take space values

What other options do I have ?

Just use xpath selector:

by.xpath("//div[contains(@class, 'container') and contains(@class, 'pageContainer')]");

Should find that specific div unless you have another div with exactly same 2 classes

Hope I helped