How can I use chrome options in vba with selenium?

自古美人都是妖i 提交于 2019-12-14 02:23:30

问题


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

回答1:


Is this what you are looking for?

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


来源:https://stackoverflow.com/questions/45121955/how-can-i-use-chrome-options-in-vba-with-selenium

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