selenium find element that has multiple class names

  • 1 Replies
  • 7889 Views
selenium find element that has multiple class names
« on: June 02, 2016, 10:37:17 am »
I have an element with 2 classes which I need to find with selenium

Code
<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 ?

Re: selenium find element that has multiple class names
« Reply #1 on: June 06, 2016, 19:23:47 pm »
Just use xpath selector:

Code
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

 

Sitemap 1 2 3 4 5 6 7 8