如何在VBA中使用含硒的Chrome选项?

问题描述:

有什么办法可以在vba代码中使用注释掉的四行代码,以便在进入一些易于通知的网页时摆脱障碍.我找不到任何想法,因此我将能够利用它们,因为由于它们现在的状态,它会引发错误.这里是.预先感谢.

Is there any way I can use those commented out four lines in my vba code so that I can shake off barrier while entering some notifications prone webpages. I can't find any idea so that I will be able to make use of them as it is throwing error because of how they are now. Here it is. Thanks in advance.

Sub Test_stth()
Dim driver As New WebDriver

'chrome_options = WebDriver.ChromeOptions()
'prefs = {"profile.default_content_setting_values.notifications" : 2}
'chrome_options.add_experimental_option("prefs",prefs)
'driver = WebDriver.Chrome(chrome_options = chrome_options)

With driver
    .Start "chrome", "https://stackoverflow.com/documentation"
    .get "/documentation"
End With
End Sub

这是您要寻找的吗?

With driver
    .SetPreference "profile.default_content_setting_values.notifications", 2 '1 for allow 2 for block
    .Start "chrome", "https://www.facebook.com"
.
.
.