Reputation: 402
I have the below html tag generated as part of highchart
<g class="highcharts-axis-labels highcharts-xaxis-labels " data-z-index="7">
<text x="332.3333333333367" style="color:#666666;cursor:default;font-size:13;fill:#666666;" text-anchor="middle" transform="translate(0,0)" y="246" opacity="1">60</text>
<text x="886.9999999999668" style="color:#666666;cursor:default;font-size:13;fill:#666666;" text-anchor="middle" transform="translate(0,0)" y="246" opacity="1">65</text>
<text x="1441.6666666666667" style="color:#666666;cursor:default;font-size:13;fill:#666666;" text-anchor="middle" transform="translate(0,0)" y="246" opacity="1">70</text>
</g>
I am trying to extract all the text values in it and used the below command
xAxis = $('.highcharts-xaxis-labels').$$('text').getText();
I tried the browser.findelements using the XPATH as well. But with both I am getting the error message
TypeError: $(...).$$(...).getText is not a function
Upvotes: 1
Views: 2092
Reputation: 27600
The problem here is that $$
(an alias for getElements
) returns an array of elements, not just one element. An element has a getText()
method, but an array doesn't have that.
If you want to get a list of all the values, you need to map the list of elements to each element's value:
$('.highcharts-xaxis-labels').$$('text').map(textElement => textElement.getText());
Upvotes: 1