<table cellspacing="0" cellpadding="0" width="50" border="0" style="border-collapse:collapse;">
<tr class="TabUnselected" valign="top" id="MainTabControl2">
<td width="5"><img width="5" height="5" border="0" src="images\eyebrow-upper-left-corner.gif" style="border-width:0px;" /></td><td><table cellspacing="3" cellpadding="0" width="99%" border="0">
<tr>
<td class="TabCaption" align="left" valign="bottom" OnClick="selectTab(2, 11, 'MainTabControl', 'Panel', 'lblTitle', 'paneltitle', 'hfldSelectedTab');" OnMouseOver="highlightTab('MainTabControl2', 'TabUnselected', 'TabHighlighted');" OnMouseOut="resetTab('MainTabControl2', 'TabUnselected', 'TabHighlighted');" style="white-space:nowrap;">**More Details**</td></tr>
</table>
我想点击更多细节(它似乎是一个链接)。
我尝试过使用linkText但返回异常..
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with link text == More Details (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 421 milliseconds
无论如何..如何识别xpath?
//*[@OnClick='selectTab(2, 11, 'MainTabControl', 'Panel', 'lblTitle', 'paneltitle', 'hfldSelectedTab')']
通过给出xpath尝试这种方式..没有运气.. org.openqa.selenium.InvalidSelectorException:xpath表达式'// * [@ OnClick ='selectTab(2,11,'MainTabControl','Panel',' lblTitle','paneltitle','hfldSelectedTab')']'无法在WebElement中进行评估或得不到(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:157毫秒
答案 0 :(得分:0)
尝试使用以下xpath:
//tr[@id='MainTabControl2']//td[@class='TabCaption']
或者
//td[@class='TabCaption']
编辑:
如果存在相同的ID和类,您可以选择元素的text()
,如下所示:
//td[contains(text(),'**More Details**')]