【发布时间】:2025-12-07 12:10:01
【问题描述】:
我在 VBA 中编写了一个 Selenium 脚本以从下拉列表中进行选择,然后按 Done 按钮。
默认情况下,页面在其登录页面中显示Bangladesh。我需要把它改成Canada。
我的脚本从下拉列表中选择了所需的国家,但是当它应该单击Done 按钮时,它会单击其他地方,因此国家/地区保持不变。该脚本没有显示任何错误。
Sub SelectDropdown()
Dim driver As New ChromeDriver
With driver
.get "https://www.amazon.com/dp/B071V5DQ56/"
.FindElementByCss("#nav-packard-glow-loc-icon", timeout:=5000).Click
.FindElementByCss("#GLUXCountryListDropdown", timeout:=5000).Click
.FindElementById("GLUXCountryList", timeout:=5000).AsSelect.SelectByText "Canada"
.FindElementByCss("div.a-popover-wrapper button[name='glowDoneButton']", timeout:=5000).Click
End With
Stop
End Sub
这是它在登录页面中显示的内容。
【问题讨论】:
标签: excel vba selenium selenium-webdriver web-scraping