Reputation: 466
I have the following html code
<svg height="600" width="910" xmlns:xlink="http://www.w3.org/1999/xlink"
id="svgcontent" overflow="visible" x="910" y="600" viewBox="0 0 910 600">
<g style="pointer-events:all">
<text fill="rgb(0,0,0)" font-family="Sans-Serif" font-size="13" id="80-155-126"
transform="rotate(-90, 168, 126)" y="126" x="168" style="pointer-
events:inherit">A100A</text>
</g>
</svg>
I tried in the following way but didnt get succeeded
assertEquals(driver.findElements(By.xpath("//*[local-name()='svg'
and namespace-uri()='http://www.w3.org/2000/svg' and @id='svgcontent']//*[local-
name()='g' and namespace-uri()='http://www.w3.org/2000/svg']/text")).size(), 1);
Upvotes: 1
Views: 2268
Reputation: 46
try following
assertEquals(driver.findElements(By.xpath("//*[local-name()='svg' and @id='svgcontent']//*[local-name()='text']")).size(), 1);
it should work, but
assertEquals(driver.findElements(By.xpath("//*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg' and @id='svgcontent']//*[local-name()='g' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='text']")).size(), 1);
should be also ok.
Upvotes: 3