我想使用vba-selenium从多选列表框中选择几个选项。
我有谷歌它但无法找到如何在vba代码中执行此操作。 我尝试过很多东西,但不能成功。 请帮帮我。
以下是我的网页:
<select name="select" id="select_id" multiple="multiple>
<option value="value1"> some-value1 </option>
<option value="value2"> some-value2 </option>
<option value="value3"> some-value3 </option> </select>
我只是想知道如何使用vba-selenium一次选择多个选项。对于例如在上面同时选择“some-value1”,“some-value2”。
谢谢!
答案 0 :(得分:0)
解决方案是保持Control键,就像真实用户一样:
Private Assert As New Selenium.Assert
Private Keys As New Selenium.Keys
Private Sub Handle_Multi_Select()
Dim driver As New FirefoxDriver
driver.Get "http://odyniec.net/articles/multiple-select-fields"
Dim ele As WebElement
For Each ele In driver.FindElementsByXPath("//select[@name='ingredients[]']/option")
ele.Click Keys.Control
Next
driver.Quit
End Sub
最新版本: https://github.com/florentbr/SeleniumBasic/releases/latest