我有一个表(下面的屏幕截图),我想用seleniumpython标记出在同一行中有文本“Xatu Auto Test”的复选框。你知道吗
我尝试了以下两个帖子:
但我无法在我的代码中使用这些解决方案。你知道吗
我的代码:
form = self.browser.find_element_by_id("quotes-form")
try:
rows = form.find_elements_by_tag_name("tr")
for row in rows:
columns = row.find_elements_by_tag_name("td")
for column in columns:
if column.text == self.group_name:
column.find_element_by_name("quote_id").click()
except NoSuchElementException:
pass
复选框从来没有点击,我想知道我做错了什么。你知道吗
这是我用FirePath检查时的HTML:
<form id="quotes-form" action="/admin/quote/delete_multiple" method="post" name="quotesForm">
<table class="table table-striped table-shadow">
<thead>
<tbody id="quote-rows">
<tr>
<tr>
<td class="document-column">
<td>47</td>
<td class="nobr">
<td class="nobr">
<td class="nobr">
<td class="nobr">
<a title="Xatu Auto Test Data: No" href="http://192.168.56.10:5001/admin/quote/47/">Xatu Auto Test</a>
</td>
<td>$100,000</td>
<td style="text-align: right;">1,000</td>
<td class="nobr">Processing...</td>
<td class="nobr">192.168....</td>
<td/>
<td>
<input type="checkbox" value="47" name="quote_id"/>
</td>
</tr>
<tr>
</tbody>
<tbody id="quote-rows-footer">
</table>
<div class="btn-toolbar" style="text-align:center; width:100%;">
通过快速查看,我认为这行需要更改,因为您试图访问
column
的quote_id
,它应该是row
:发件人:
收件人:
另外,如果像@Saifur评论的那样,你的比较是正确的。你知道吗
更新日期:
我已经运行了一个模拟,如果将
column
更改为row
,简化版本,则确实选中了复选框:输出如下:
相关问题 更多 >
编程相关推荐