单击元素(按子文本选择)

时间:2018-10-11 07:27:36

标签: node.js puppeteer

我需要点击带有表格的页面上的复选框:

<table>
   ....sample item...
    <tr>                 
    <td align="middle"><input type="checkbox" class="enableMacacl" checked=""></td>
    <td>04:18:D6:3E:B4:79</td> 
    </tr>
</table>

但是我需要通过文本“ 04:18:D6:3E:B4:79”单击带有选择器的复选框。我该怎么办?

1 个答案:

答案 0 :(得分:0)

您需要将其包装在<label for="checkboxId"></label>中,然后将id="checkboxId"放入复选框。

<table>
   ....sample item...
    <tr>                 
    <td align="middle"><input type="checkbox" id="checkbox" class="enableMacacl" checked=""></td>
    <td><label for="checkbox">04:18:D6:3E:B4:79</label></td> 
    </tr>
</table>
相关问题