【发布时间】:2019-01-29 22:17:55
【问题描述】:
您好,我是通过 VBA 接触 selenium 的新手,我正在尝试选择下拉列表,我需要从下拉列表中选择一个选项,即复选框。很遗憾,我无法分享链接。
我尝试了一些代码但它不起作用,下面是我尝试的代码
bot.FindElementByXPath("//*[contains(text(),'GT - ALL')]").Click
这是网页元素
<div class="form-group">
<label for="billerId"> Mid </label><br>
<select name="billerId" id="billerId" class="billerId form-control" multiple="multiple" style="display: none;">
<option value="7">(7) Pay</option>
<option value="11">(11)</option>
<option value="GT1">(1) GT - ALL</option>
<option value="GT7">(7) GT - S1- LB</option>
<option value="GT8">(8) GT - S2 - LB</option>
<option value="GT9">(9) GT - S3</option>
<option value="GT6">(6) GT Whistle</option>
<option value="GT4">(4) GT -LB</option>
<option value="1">(1) Main - PP (2)</option>
<option value="4">(4) MTEST</option>
<option value="2">(2) test</option>
<option value="12">(12) RR1</option>
<option value="10">(10) RR Data</option>
<option value="8">(8) RR 2Mid</option>
<option value="9">(9) RR 3</option>
<option value="6">(6) Silver New PP </option>
<option value="5">(5) SILVER </option>
<option value="3">(3) Strike</option>
</select>
<div class="ms-parent billerId form-control"><button type="button" class="ms-choice"><span class="placeholder">All</span><div class=""></div></button>
<div class="ms-drop bottom" style="display: none;">
<div class="ms-search"><input type="text" autocomplete="off" autocorrect="off" autocapitilize="off" spellcheck="false"></div>
<ul style="max-height: 250px;">
<li class="ms-select-all"><label><input type="checkbox" data-name="selectAllbillerId">[Select All]</label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="7"><span>(7) </span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="11"><span>(11) </span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="GT1"><span>(1) GT - ALL</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="GT7"><span>(7) GT - LB</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="GT8"><span>(8) GT - S2 - 02/11/17 LB</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="GT9"><span>(9) GT - S3</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="GT6"><span>(6) GT Whistle</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="GT4"><span>(4) GT -LB</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="1"><span>(1) Main - PP (2)</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="4"><span>(4) MTEST</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="2"><span>(2) test</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="12"><span>(12) RR1</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="10"><span>(10) RR Data</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="8"><span>(8) RR 2Mid</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="9"><span>(9) RR 3</span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="6"><span>(6) Silver New PP </span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="5"><span>(5) SILVER </span></label></li>
<li class="" style="false"><label class=""><input type="checkbox" data-name="selectItembillerId" value="3"><span>(3) Strike</span></label></li>
<li class="ms-no-results" style="display: none;">No matches found</li>
</ul>
</div>
【问题讨论】:
-
请解释一下不起作用是什么意思?
标签: excel vba selenium-webdriver web-scraping