|
执行Edge浏览器的时候,弹出Cannot start the driver service on http://localhost:53116, 楼主,能帮我解释一下什么原因吗?
Private WD As SeleniumBasic.IWebDriver
Sub Baidu()
On Error GoTo Err1
Dim Service As SeleniumBasic.EdgeDriverService
Dim Options As SeleniumBasic.EdgeOptions
Set WD = New SeleniumBasic.IWebDriver
Set Service = New SeleniumBasic.EdgeDriverService
With Service
' .CreateDefaultService driverPath:="E:\Selenium\Drivers", driverexecutablefilename:="MicrosoftWebDriver.exe"
.CreateDefaultService driverPath:="C:\Program Files (x86)\Microsoft\Edge\Application", driverexecutablefilename:="msedge.exe"
.HideCommandPromptWindow = True
End With
Set Options = New SeleniumBasic.EdgeOptions
With Options
.StartPage = "https://www.cnblogs.com/ryueifu-VBA/"
End With
WD.New_EdgeDriver Service:=Service, Options:=Options
WD.Navigate_GoToUrl "https://www.baidu.com"
Dim form As SeleniumBasic.IWebElement
Dim keyword As SeleniumBasic.IWebElement
Dim button As SeleniumBasic.IWebElement
Set form = WD.FindElementById("form")
Set keyword = form.FindElementById("kw")
keyword.Clear
keyword.SendKeys "好看视频"
Set button = form.FindElementById("su")
button.Click
Debug.Print WD.Title, WD.URL
Debug.Print WD.PageSource
MsgBox "下面退出浏览器。"
WD.Quit
Exit Sub
Err1:
MsgBox Err.Description, vbCritical
End Sub |
|