我需要能够从下拉列表中选择一个项目(列表中的项目是复选框),但我似乎无法正确获取代码。网页是一个内部网站,所以我无法提供实际的链接,但是这里有元素:
要激活下拉列表:
<input name="m_sqlRsWebPart$ctl00$ctl19$ctl06$ctl09$txtValue" type="text" size="28" readonly="readonly" id="m_sqlRsWebPart_ctl00_ctl19_ctl06_ctl09_txtValue" title="Support Group report parameter" class="null">
我需要的列表中的项目是:
<input id="m_sqlRsWebPart_ctl00_ctl19_ctl06_ctl09_divDropDown_ctl184" type="checkbox" name="m_sqlRsWebPart$ctl00$ctl19$ctl06$ctl09$divDropDown$ctl184" onclick="$get('m_sqlRsWebPart_ctl00_ctl19_ctl06_ctl09').control.OnValidValueClick(this, 'm_sqlRsWebPart_ctl00_ctl19_ctl06_ctl09_divDropDown_ctl00');">
到目前为止我尝试的是(摘录):
driver.find_element_by_name("m_sqlRsWebPart$ctl00$ctl19$ctl06$ctl09$txtValue").click()
driver.find_element_by_id("m_sqlRsWebPart_ctl00_ctl19_ctl06_ctl09_divDropDown_ctl184").click()
什么都不做。
列表框的完整HTML:
<div onactivate="event.cancelBubble=true;" style="white-space:nowrap;">
<input name="m_sqlRsWebPart$ctl00$ctl19$ctl06$ctl09$txtValue" type="text" size="28" readonly="readonly" id="m_sqlRsWebPart_ctl00_ctl19_ctl06_ctl09_txtValue" title="Support Group report parameter" class="null"><input src="/sites/pa/reports/Reserved.ReportViewerWebPart.axd?OpType=Resource&Version=11.0.5058.0&Name=Microsoft.Reporting.WebForms.Icons.MultiValueSelect.gif" name="m_sqlRsWebPart$ctl00$ctl19$ctl06$ctl09$ddDropDownButton" type="image" id="m_sqlRsWebPart_ctl00_ctl19_ctl06_ctl09_ddDropDownButton" alt="Select a value" title="Select a value" style="vertical-align:top;cursor:pointer;">
</div>