html - About xpath in table java
问题描述
I am trying to find the xpath of the button(its an input for real) from the name of the person in the corresponding line.
the right "connection" button from the name.
I have tried several xpath may saucun do not click the button I want.
It Clicks on the first button of the whole table each time
I tried this:
*d.driver.findElement(By.xpath("//tr/td[contains(text(), 'TOTO')]/following-sibling::td/input"));
and
*d.driver.findElement(By.xpath("//td[contains(text(), 'TOTO')]/following-sibling::td/input"));
and
*d.driver.findElement(By.xpath("//tr/td[contains(text(), 'TOTO')]/following-sibling::td/input[type='submit']"));
and
*d.driver.findElement(By.xpath("//tr/td[contains(text(),'TOTO')]//td[5]/input"));
I enclose the table.
Here is the HTML code :
<tr>
<td>FR1547</td>
<td>CAILLOUX</td>
<td>CHRISTIANE</td>
<td></td>
<td></td>
<td>UTILISATEUR</td>
<td><input value="connection" onclick="document.getElementById('hiddenCuid').value = 'FR1547'" type="submit"></td>
</tr>
<tr>
<td>US7784</td>
<td>TOTO</td>
<td>CHRISTINE</td>
<td></td>
<td></td>
<td>UTILISATEUR</td>
<td><input value="connection" onclick="document.getElementById('hiddenCuid').value = 'US7784'" type="submit"></td>
</tr>
Second button :
<tr>
<td>US4487</td>
<td>PONT</td>
<td>CHRISTIANE</td>
<td></td>
<td></td>
<td>UTILISATEUR, MANAGER</td>
<td><input value="connection" onclick="document.getElementById('hiddenCuid').value = 'US4487'" type="submit"></td>
</tr>
解决方案
try this xpath :
//td[text()='TOTO']/parent::tr/child::input
推荐阅读
- javascript - 如何在 html/css/js 中呈现跨媒体栏(PS3 UI)
- shopify - 如何在shopify中获取付款方式
- javascript - 在我的浏览器控制台上调用 ajax 时得到“[Deprecation]”
- python - 当另一列值更改python时创建具有行号的列
- r - 如何重新排序我的 X 轴,以便我的样本根据它们所属的组进行分组
- amazon-web-services - 如何将 AWS Cloudwatch 日志插入数据库?
- haskell - 如何从 Haskell 中的文件中读取字节数组?
- javascript - 如何连接对象和参数中的特定值
- javascript - 使用 .map() 或 .filter() 函数对 Array 中的对象进行分组
- haskell - Haskell 运行时如何区分指针和未装箱的字大小值?