我有以下HTML代码:
<div class="menu">
<ul class="operation">
<li class="menu_icon selected" id="icon_oper-agents">
<div id="title_menu" style="color:#FFF; padding-top:12px; display:none;">Monitoring</div>
<ul id="subicon_oper-agents" class="submenu invisible" style="display: none;">
<li id="Views" class="has_submenu submenu_selected selected">
<div class=" SubNoLink submenu_text submenu_text_middle">Views</div>
<ul id="subViews" class="submenu2" style="display: none;">
<li class="sub_subMenu" style="">
<a href="index.php?sec=view&sec2=operation/agentes/estado_agente">
<div class="submenu_text submenu2_text_middle" title="">Agent detail</div>
</a>
</li>
<li class="sub_subMenu" style="">
<a href="index.php?sec=view&sec2=extensions/realtime_graphs">
<div class="submenu_text submenu2_text_last" title="">Real-time graphs</div>
</a>
</li>
</ul>
</li>
</ul>
</div>
</li>
</ul>
</div>
我需要使用XPATH访问链接“index.php?sec = view&amp; sec2 = operation / agentes / estado_agente”(,其文本是代理详细信息)。
我已经有了这个,但没有用:
'//*[@id="subViews"]/li[4]/a'
我需要这个Xpath表达式来创建一个python函数,该函数使用selenium Webdriver客户端接受“Agent detail”作为参数,并返回表示它的Web元素。
<li class="sub_subMenu" style="">
<a href="index.php?sec=view&sec2=operation/agentes/estado_agente">
<div class="submenu_text submenu2_text_middle" title="">Agent detail</div>
</a>
</li>
答案 0 :(得分:1)
如果您想获取链接://ul[@id="subViews"]//a[contains(.,"Agent detail")]
如果你想得到它的href值://ul[@id="subViews"]//a[contains(.,"Agent detail")]/@href