【发布时间】:2021-11-09 12:28:42
【问题描述】:
我有以下 HTML:
<div _ngcontent-yei-c89="" class="folder-content__tile-view"><div _ngcontent-yei-c89="" class="widget">
<div _ngcontent-yei-c89="" soho-widget-header="" class="widget-header">
<button _ngcontent-yei-c89="" soho-button="icon" icon="more" soho-context-menu="" menu="action-popupmenu" trigger="click" class="btn-actions btn-icon has-tooltip" type="button" aria-pressed="false" aria-haspopup="true" aria-controls="action-popupmenu">
<svg soho-icon="" aria-hidden="true" focusable="false" role="presentation" class="icon">
<use href="#icon-more"></use>
</svg>
<!---->
<span></span>
</button><!----><!----></div>
<div _ngcontent-yei-c89="" soho-widget-content="" class="widget-content"><!----><!---->
<svg _ngcontent-yei-c89="" soho-icon="" icon="map" aria-hidden="true" focusable="false" role="presentation" class="icon">
<use href="#icon-map"></use>
</svg><!----><!---->
<h1 _ngcontent-yei-c89="" soho-tooltip="" class="ellipsis has-tooltip">Process Map</h1>
<h2 _ngcontent-yei-c89=""> Sep 14, 2021, 11:47:25 AM </h2>
</div>
</div>
我想通过使用图标作为唯一 ID 来获取 <button> 的 xpath://*[local-name()='svg'][*[local-name()='use'][@href="#icon-map"]]。此路径有效,但我不确定如何从此处获取按钮。
【问题讨论】:
-
试试这个
//*[local-name()='svg'][*[local-name()='use'][@href="#icon-map"]]//parent::div//parent::button -
#icon-map 与 button 无关,您的意思是 icon-more 吗?为什么不能在该 html 中使用任何其他属性
标签: html selenium xpath robotframework