Run-time error '21' (VBA + Selenium+Chrome)

大憨熊 提交于 2021-01-01 04:20:56

问题


Code is working well but after running several times it stuck with Run-time error '21'.

It cannot open webdriver with run-time error '21': as attached picture.

'bot. start "Chrome" which is the code that has the error.

Chrome version: 83.0.4103.97

Selenium: SeleniumBasic-2.0.9.0

enter image description here

Dim bot As New WebDriver
Dim ele As WebElement
Dim picEle As WebElement
Dim awbaLI As WebElements
Dim AWB As List


bot.Start "Chrome"

bot.Get "https://google.com"

回答1:


The error message says that you Port (62982, according to your provided screenshot) is still in use and thus cannot be reused.

You must also close to bot instance in order to release the port again (this also explains why it works again when you restart your PC (because then all the ports are released automatically) In this case this can be done by calling bot.Quit at the very end of your bot usage / script!



来源:https://stackoverflow.com/questions/64585947/run-time-error-21-vba-seleniumchrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!