L
L
Loligan2016-10-27 11:06:34
HTML
Loligan, 2016-10-27 11:06:34

How to find a button belonging to a row with a specific name in a column using XPath?

How do I get a button in a row that has an entry named Lois in the first column using XPath?
AmCIn.png

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
}
</style>
</head>
<body>

<h2>Add a border to a table:</h2>

    <table>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
      </tr>
      <tr>
        <td>Peter</td>
        <td>Griffin</td>
        <td><button type="button">Click!</button></td>
      </tr>
      <tr>
        <td>Lois</td>
        <td>Griffin</td>
        <td><button type="button">Click!</button></td>
      </tr>
    </table>

    </body>
    </html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2016-10-27
@Loligan

It's so easy:
//tr[td[contains(text(), "Lois")]]/td/button

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question