python - 单击 Python Selenium 中特定行上表中的按钮

标签 python selenium xpath webdriverwait xpath-1.0

我有一个包含表格和几行的页面,其中某些行与其他行具有相同的文本。

如果同一行上的文本包含 <td class="user_type"> 中的文本“real”,我想单击“删除”按钮真实的 .

<tr id="5gf5h5gh4rthhgh1" data-id="1418753">
    <td class="website">www.123.com</td>
    <td class="user_type">real</td>
    <td class="ip_address">123.123.1.1 ()</td>
    <td class="actions">
        <div class="list-action">   
            <button class="btn default check check green markAsChecked" type="button">
                <i class="fa fa-check green markAsChecked"></i>Delete</button></div></td>
</tr>

<tr id="5gf5h5gh4g5j1gh4" data-id="1418753">
    <td class="website">www.123.com</td>
    <td class="user_type">virtual</td>
    <td class="ip_address">88.123.2.2 ()</td>
    <td class="actions">
        <div class="list-action">   
            <button class="btn default check check green markAsChecked" type="button">
                <i class="fa fa-check green markAsChecked"></i>Delete</button></div></td>
</tr>

最佳答案

您可以尝试以下xpath:

//tr//td[@class="user_type" and text()="real"]//following-sibling::td//button[text()="Delete"]

关于python - 单击 Python Selenium 中特定行上表中的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63614157/

相关文章:

Python-将带分数转换为 float

java - 自动化安装过程

selenium - 为什么在 Protractor 中使用 locator()?

xml - 使用Powershell删除节点

xml - 在 xpath 表达式中不使用命名空间

python - pyplot 放大

python - 类实例的类声明和操作

python - 了解 Airflow 中的execution_date

python - 有没有办法在我使用 python-selenium 的同时在 heroku 上使用 chrome 驱动程序?

xpath - VTD 2.13 发现使用节点值条件评估 xpath 的错误节点