我有一个类似这样的html:
<table>
<tbody>
<tr>
<td> John Doe</td>
<td> <a href="http://example.com/1/edit">Edit</a> </td>
</tr>
<tr>
<td> Robert Smith </td>
<td> <a href="http://example.com/2/edit"> Edit </a> </td>
</tr>
</tbody>
</table>
我想单击John Doe
的编辑链接。我该怎么办? WebDriverBy::xpath
有可能吗?
答案 0 :(得分:1)
您可以使用XPath:
$selector = "//td[normalize-space()='John Doe']/following-sibling::td/a";
$browser->driver->findElement(WebDriverBy::xpath($selector))->click();