d-b
d-b

Reputation: 971

Xpath - find all cells in a table with a certain property

I have a table that is defined like this

<div class="wrap-4-columns product-list box">

(followed by a couple of levels of other divs)

Then the div with main content looks like this

<div class="product-inner-wrap">
   <div class="info-col grid-columns">
       Actual content
   </div>
</div>

Finally, on some of the cells, there is a span at the same level as the <div class="info-col grid-columns">

<span class="js-sale badge disrupter">Some text</span>

Currently the table has 4 columns with 6 cells. That is, the first row has four elements and the second row two elements. Row 1 column 3 (R1C3) and R2C2 have this span. I want to select the content of <div class="info-col grid-columns"> of all cells with the span <span class="js-sale badge disrupter">Some text</span>

Can this be done?

//div[@class="product-inner-wrap"]//div[@class="info-col grid-columns"]...then what?

Upvotes: 0

Views: 34

Answers (1)

KunduK
KunduK

Reputation: 33384

Try the below xpath with multiple attributes.

//div[@class="product-inner-wrap"]//div[@class="info-col grid-columns"]//span[@class="js-sale badge disrupter"][contains(.,"Some text")]

Or

//div[@class="product-inner-wrap"]//div[@class="info-col grid-columns"]//span[contains(.,"Some text")]

Upvotes: 1

Related Questions