【发布时间】:2023-04-05 01:31:01
【问题描述】:
我可以从 SVG 中的文本标签中获取文本。我正在附加 HTML
<svg width="553" height="200" style="overflow: hidden;" aria-label="A chart.">
<defs id="defs">
<rect x="0" y="0" width="553" height="200" stroke="none" stroke-width="0" fill="#ffffff">
<g>
<text text-anchor="start" x="77" y="22.85" font-family="Arial" font-size="11" font-weight="bold" stroke="none" stroke-width="0" fill="#000000">Clustering done on Mar 30, 2017 11:13 AM</text>
<rect x="77" y="13.5" width="400" height="11" stroke="none" stroke-width="0" fill-opacity="0" fill="#ffffff">
</g>
我想得到的是Clustering done on Mar 30, 2017 11:13 AM
【问题讨论】:
-
请在您尝试获取文本的地方发布代码
-
'String text=driver.findElement(By.xpath(".//[@id='divClusters']/div[1]/div[1]/div/svg/g[1] ]/text")).getText();' System.out.print(文本)
-
这是错误信息org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element @japu-d-cret
标签: java html selenium testing svg