【发布时间】:2020-06-22 22:59:14
【问题描述】:
我一直在尝试关闭打开链接时出现的弹出窗口。
我尝试使用 Xpath 在弹出窗口上单击关闭按钮,但代码不断打开一个新页面,显然单击了错误的链接左右。
这是我正在尝试的代码。
Public Sub scrapeCIL2()
Dim bot As New WebDriver, btn As Object, i As Long, pageCount As Long
Dim wins As Variant
bot.Start "chrome", "https://duproprio.com/en/search/list?search=true&regions%5B0%5D=6&is_for_sale=1&with_builders=1&parent=1&pageNumber=2&sort=-published_at"
bot.Get "/"
pageCount = bot.FindElementsByClass("pagination__item").Count
Application.Wait Now + TimeValue("00:00:02")
'To click the close button of the popup
bot.FindElementByXPath("//*[@id='react-component-InfoSessionsPopup']/div/div/div[1]").Click
bot.Quit
End Sub
任何使用 Selenium VBA 关闭此弹出窗口的帮助将不胜感激
【问题讨论】:
标签: excel vba selenium web-scraping