Kinga
Kinga

Reputation: 232

Searching text in xpath

I have a line chart and I need to write an XPATH expression to find two lines on my chart. Each line is presented like below

<path id="plot0" 
      class="serie-line" 
      d="M0,467.8474476246681L13.001330376940134,162.45979640011808L18.696418022842323,309.98340218353496L20.963279923022217,372.2558276777811L43.710684014558844,258.2812038949543L52.126722168765426,479.3368250221305L167.4494716144417,156.7151077013869L177.8337045559135,440.9623045146061L179.47959670334268,501.166642077309L194.66005103961845,258.51099144290356L197.98800485294734,325.60895544408385L204.5174982219805,507.1411183239894L214,171.65129831808798" 
      style="stroke: rgba(255, 102, 102, 0.701961);">
</path>

When I use $x("//*[@id='plot0']") I got an array with 1 element (good).

When I add contains the result is empty array $x("//*[@id='plot0' and contains(text(),'rgba')]")

What should I change in the expression?

Upvotes: 2

Views: 98

Answers (1)

JLRishe
JLRishe

Reputation: 101652

Your plot element doesn't contain any text nodes, and certainly none that have the value rgba in them. This is almost surely what you want:

$x("//*[@id='plot0' and contains(@style, 'rgba')]")

Upvotes: 2

Related Questions