Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xpath 根据单元格内容选择表行中的链接_Xpath_Selenium Ide - Fatal编程技术网

Xpath 根据单元格内容选择表行中的链接

Xpath 根据单元格内容选择表行中的链接,xpath,selenium-ide,Xpath,Selenium Ide,使用Selenium IDE,我试图在表行中定位链接。表行是动态生成的。每行都有一些包含文本内容的单元格和一个可能包含两个或更多链接的单元格 我想做的是创建一个自动测试,单击特定文本引用的特定行中的特定链接。例如,在下表中: <html> <body> <table border="1"> <tr> <td> Hello World! </td> <td> Type Greet

使用Selenium IDE,我试图在表行中定位链接。表行是动态生成的。每行都有一些包含文本内容的单元格和一个可能包含两个或更多链接的单元格

我想做的是创建一个自动测试,单击特定文本引用的特定行中的特定链接。例如,在下表中:

<html>
<body>
<table border="1">
 <tr>
   <td>
    Hello World!
   </td>
   <td>
    Type Greeting
   </td>
   <td>
    <a href="www.foo.com/view/id=123456">View</a>
    <a href="www.foo.com/delete/id=123456">Delete</a>
   </td>
 </tr>
 <tr>
   <td>
    Buenos Dias!
   </td>
   <td>
    Type Greeting 
   </td>
   <td>
    <a href="www.foo.com/view/id=789101">View</a>
    <a href="www.foo.com/delete/id=789101">Delete</a>
   </td>
 </tr>
</table>
</body>
</html>
但我想以某种方式将其用作从表中查找其各自视图链接的参考。我尝试了兄弟格式如下,之前,我似乎无法让它工作的权利。使用绝对xpath html/body/table/tbody/tr[1]/td[3]/a[1]将不起作用,因为数据可能会更改,并且条目显示在不同的行上

提前谢谢,如果您需要更多信息,请告诉我

硒IDE 1.7.2 火狐9.0.1 Mac OS X Lion 10.7.3 使用:

使用:


//td[normalize space=Buenos Dias!][1]/以下兄弟姐妹::td[2]/a[.='View']

/td[normalize space=Buenos Dias!][1]/以下兄弟姐妹::td[2]/a[.='View']

//td[text()="Buenos Dias!"] 
(//td[normalize-space() ="Buenos Dias!"])[1]/following-sibling::td[2]/a[. = 'View']
//find table first
 WebElement q=  d.findElement(By.xpath("//*[@id='applicationcontent']/div[6]/table/tbody/tr"));

// find a unique value of the row and click on link of the row which is after the text you find.
         q.findElement(By.xpath("//td[contains(text(),'abcd@gmail.com')]/following-sibling::td/a[@id='edit.png']")).click();