【发布时间】:2019-10-10 23:09:01
【问题描述】:
我正在尝试从图表上不可见的 SVG 元素内部获取文本值。但是,当我将鼠标悬停在它上面时,它会给出工具提示值
我可以将鼠标悬停在元素上,但无法获取值。
@FindBy(how=How.XPATH,using = "//*[name()='svg']//*[name()='g']//*[contains(@class,'')]//*[@visibility='hidden']")
public static WebElement newgraph;
new Actions(driver).moveToElement(newgraph).clickAndHold().moveByOffset(0, 0).pause(1000).perform();
/* Actions builder = new Actions(driver);
builder.moveToElement(newgraph).perform();*/
String tooltip_msg = newgraph.getText();
System.out.println(tooltip_msg);
以下是 HTML
<g class="highcharts-label highcharts-tooltip highcharts-color-undefined"
style="cursor:default;pointer-events:none;white-space:nowrap;"
transform="translate(212,-9999)" opacity="0" visibility="visible"><path
fill="none" class="highcharts-label-box highcharts-tooltip-box"
isShadow="true" stroke="#000000" stroke-opacity="0.049999999999999996"
stroke-width="5" transform="translate(1, 1)"><text x="8" style="font-
size:12px;color:#333333;fill:#333333;" y="20">
<tspan style="font-weight:bold; fill:#4fb3c3">Licensed: </tspan><tspan
style="font-weight:bold" dx="0">560</tspan><tspan x="8" dy="15">May 24,
2019</tspan></text>
</g>
</svg>
【问题讨论】:
-
我要值2019年5月24日
标签: java selenium svg ui-automation