Selenium测试的javascript XPath标识
我不熟悉Selenium和XPath。您能帮我正确识别以下结构的XPath吗:
<body>
<div id="body-wrapper">
<div id="outer-wrapper">
<div id="wrap2">
<div class="span-24">
<div style="clear: both;"/>
<div id="header-wrapper">
<div style="clear: both;"/>
<div class="span-24">
<div class="menu-secondary-container">
<ul class="menus menu-secondary">
<li>
<li>
<li class="">
<a class="sf-with-ul" href="#">
Automation
<span class="sf-sub-indicator">»</span>
<span class="sf-sub-indicator">»</span>
</a>
<ul class="children sub-menu" style="display: none; visibility: hidden;">
<li>
<a href="http://www.ufthelp.com/p/uft.html" title="UFT">UFT</a>
</li>
我已将XPath标识为:
("//div[@class='menutext']/descendant::ul[@class='children sub-menu']/a[@href='http://www.ufthelp.com/p/uft.html']"));
但我遇到了NoSuchElementException
。请帮我做同样的事。谢谢
# 1 楼答案
`
`
# 2 楼答案
XPATH:
//a[@title='UFT']
或者
//a[text()='UFT']
CSS:
a[title='UFT']
# 3 楼答案
你可以在firofox浏览器中使用firebug扩展轻松获取Xpath。只需按元素u进行选择即可获得xpath值。FirePath是一个Firebug扩展,它添加了一个用于编辑、检查和生成XPath的开发工具