Как мне связать contains
и «не содержит» в xpath?
Я хочу убедиться, что кнопка имеет класс add-to-cart-button
и не имеет класса btn--disabled
.
Как я могу это сделать? Вот что у меня есть:
button[contains(@class, "add-to-cart-button")]
РЕДАКТИРОВАТЬ: В моем проекте у меня есть список продуктов. Теперь я хочу выбрать первый Article-Container на странице, кнопка которого не имеет класса btn--disabled
Вот HTML
<main>
<div class="grid shop-list__results offer-tiles">
<div class="offer-tiles__item offer-tiles--odd offer-tiles--top-border">
<article itemscope="itemscope" itemtype="http://schema.org/Product" class="offer-tile">
<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="offer-tile__content">
<ul class="offer-tile__actions">
<li class="offer-tile__action offer-tile__action--add-to-cart">
<button type="button" class="btn add-to-cart-button btn--disabled">Cart</button></li>
</ul>
</div>
</article>
</div>
<div class="offer-tiles__item offer-tiles--even offer-tiles--top-border">
<article itemscope="itemscope" itemtype="http://schema.org/Product" class="offer-tile">
<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="offer-tile__content">
<ul class="offer-tile__actions">
<li class="offer-tile__action offer-tile__action--add-to-cart">
<button type="button" class="btn add-to-cart-button">Cart</button></li>
</ul>
</div>
</article>
</div>
А вот мой селектор xpath (это, очевидно, неправильно):
//main//article[contains(descendant::button/@class, "add-to-cart-button")][not(descendant::button/@disabled)]