htmlcssrubyseleniumwatir-webdriver

How to find element by watir-webdriver using more than one class?


For example, we have element like this: <div class="first_class second_class"></div>

So we can find using it's classes:

But what is about multiple search? Can I use combination of them?


Solution

  • In this case, use a CSS selector directly:

    browser.div(css: '.first_class.second_class')
    

    Note that the "by class" locator is actually transformed to a "by CSS selector" under the hood.