class Capybara::Selector::XPathBuilder

def class_conditions(classes)

def class_conditions(classes)
  case classes
  when XPath::Expression
    XPath.attr(:class)[classes]
  when Regexp
    XPath.attr(:class)[regexp_to_xpath_conditions(classes)]
  else
    Array(classes).map do |klass|
      if klass.start_with?('!')
        !XPath.attr(:class).contains_word(klass.slice(1..-1))
      else
        XPath.attr(:class).contains_word(klass)
      end
    end.reduce(:&)
  end
end