如何为此找到Xpath?
How to find Xpath for this?
<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>
我想点击更多详细信息(好像是link)。
我尝试使用 linkText 但 returns 异常..
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 毫秒
尝试使用以下 xpath:
//tr[@id='MainTabControl2']//td[@class='TabCaption']
或者
//td[@class='TabCaption']
已编辑:
如果存在相同的 id 和 class,您可以 select 与元素的 text()
如下:
//td[contains(text(),'**More Details**')]
<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>
我想点击更多详细信息(好像是link)。
我尝试使用 linkText 但 returns 异常..
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 毫秒
尝试使用以下 xpath:
//tr[@id='MainTabControl2']//td[@class='TabCaption']
或者
//td[@class='TabCaption']
已编辑:
如果存在相同的 id 和 class,您可以 select 与元素的 text()
如下:
//td[contains(text(),'**More Details**')]