Rares Pasca
Rares Pasca

Reputation: 21

How do i get text from a dynamic element with selenium?

So this is my xpath :

.//*[@id='highcharts-m6xwk29-6']/svg/rect[1]

Every time you refresh or access the page , this part "m6xwk29-6" changes with random characters and numbers . I have tried with contains but it does not work at all . This is the CssSelector :

#highcharts-efwz4kr-2 > svg > text:nth-child(23)

I just wanna get the text from this element . The html for this element is the following :

<text x="635" text-anchor="end" class="highcharts-plot-line-label " transform="translate(0,0)" style="font-size:14px;font-weight:bold;color:#dedede;fill:#dedede;" y="86" visibility="visible">1.07162</text>

The text that i wanna get is a value (in this case 1.07162) from a graph that updates every second (or less) .

Upvotes: 0

Views: 1995

Answers (1)

Andersson
Andersson

Reputation: 52665

Try to use below XPath:

'//*[starts-with(@id, "highcharts-")]/*[name()="svg"]/*[name()="text"]'

Upvotes: 3

Related Questions