I met a problem when I try to get an attribute of one tag.
Here is the html code:
<rect x="66.5" y="43.5" width="26" height="13" fill="#86E067" stroke="#ffffff" stroke-width="1" class="highcharts-point "></rect>
Here is the xpath for that html:
//*[@id="highcharts-z14trt3-4"]/svg/g[6]/g[1]/rect[2].
I copied this xpath from Chrome directly,
I am trying to get the attribute height, and here is what I did:
WebElement test = driver.findElement(By.xpath("//*[starts-with(@id,'highcharts')]/svg/g[6]/g[1]/rect[2]"));
I cannot use tagName as there are many tags called rect. Meanwhile, I cannot use the exactly same XPath as the id is dynamic.
So the result is that selenium says cannot locate the element.
Is the way I try to locate this element wrong? Any suggestions?