无法找到SVG元素的Xpath

问题描述 投票:0回答:2

无法找到SVG元素的xpath。这是SVG的HTML部分

<visual-modern _ngcontent-qqf-c10="" _nghost-qqf-c17="">
<div _ngcontent-qqf-c17="" class="visual visual-card allow-deferred-rendering" focus-nav-mode="Group" initialized="">
<svg width="146.60231660231662" height="65.98455598455598" class="card setFocusRing" tabindex="0" focusable="true" aria-label="Total Sales Reps 171." pbi-focus-tracker-idx="3">
<g transform="translate(73.30115830115831,36.98446549227799)"><text class="value" style="text-anchor: middle; fill: rgb(162, 123, 53); font-family: wf_standard-font, helvetica, arial, sans-serif; font-size: 32px; white-space: pre;">171<title>171</title></text></g><g transform="translate(73.30115830115831,61.00009049227799)"><text class="label" style="fill: rgb(80, 62, 27); font-family: &quot;Segoe UI&quot;, wf_segoe-ui_normal, helvetica, arial, sans-serif; font-size: 12px; text-anchor: middle; white-space: pre;">Total Sales Reps<title>Total Sales Reps</title></text></g><div class="caption" style=""></div></svg></div></visual-modern>

相对和绝对Xpath已经累了。

<visual-modern _ngcontent-qqf-c10="" _nghost-qqf-c17="">
<div _ngcontent-qqf-c17="" class="visual visual-card allow-deferred-rendering" focus-nav-mode="Group" initialized="">
<svg width="146.60231660231662" height="65.98455598455598" class="card setFocusRing" tabindex="0" focusable="true" aria-label="Total Sales Reps 171." pbi-focus-tracker-idx="3">
<g transform="translate(73.30115830115831,36.98446549227799)"><text class="value" style="text-anchor: middle; fill: rgb(162, 123, 53); font-family: wf_standard-font, helvetica, arial, sans-serif; font-size: 32px; white-space: pre;">171<title>171</title></text></g>
<g transform="translate(73.30115830115831,61.00009049227799)"><text class="label" style="fill: rgb(80, 62, 27); font-family: &quot;Segoe UI&quot;, wf_segoe-ui_normal, helvetica, arial, sans-serif; font-size: 12px; text-anchor: middle; white-space: pre;">Total Sales Reps<title>Total Sales Reps</title></text></g><div class="caption" style=""></div></svg></div></visual-modern>
selenium svg xpath automation
2个回答
0
投票
如果aria标签值是唯一的,它将起作用。要积累您的xpath知识,您可以使用一些xpath配方来检查此document

0
投票
[[name()='svg'] / [name()='g'] [1] /

[[name()='g'] /

© www.soinside.com 2019 - 2024. All rights reserved.