1

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
SIM
  • 21,997
  • 5
  • 37
  • 109
  • Hi SMth80! Do you get a Runtime Error 0: WebRequestError? – Tehscript Jul 15 '17 at 19:33
  • Thanks Tehscript, for you comment. It is always a great pleasure to find you in the loop. Actually, I can't run them at all cause the two lines within the four commented out lines are marked with red color. First one is for curly braces and the second one is for dot operator. – SIM Jul 15 '17 at 19:39
  • When you ignore these 4 lines, what error do you get? – Tehscript Jul 15 '17 at 19:39
  • No error at all. I've randomly used selenium with vba already. Basically, I want to use these four lines in my script. Is it possible? – SIM Jul 15 '17 at 19:42
  • Can you explain how do you want to pass the barrier, what exactly do you need to bypass the notifications? – Tehscript Jul 15 '17 at 19:46
  • Sure. Gonna give you a link with my script in a while. – SIM Jul 15 '17 at 19:51
  • Here goes the link with a little description: "https://www.dropbox.com/s/2na6nfvipmsobat/For%20Tehscript.txt?dl=0" – SIM Jul 15 '17 at 20:02

1 Answers1

6

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"
.
.
.
Tehscript
  • 2,556
  • 2
  • 13
  • 23
  • 1
    You are the wizard of vba, Tehscript. For the last few months I have been looking for this workaround but you did it with a one liner code. The other day you gave me another solution concerning lazy-loading webpage using SendKeys "{end}", which is still second to none.Thanks once again.. – SIM Jul 15 '17 at 20:44
  • One last thing, I've got another issue concerning the loop I've used in my script in the dropbox link. That is x= o to 50. I used this figure randomly to get all the results of that lazy-loaing page and it works but I wanted to use that loop without hardcoding any number. If you have time I can create another thread describing the issue and give here a link. – SIM Jul 15 '17 at 20:45
  • Of course, go for it, I will have a look into it when you are done. Thanks for the kind words. – Tehscript Jul 15 '17 at 20:48
  • 1
    FYI: see the examples in the selenium install folder on your computer. on mine it is at _C:\Users\js\AppData\Local\SeleniumBasic\Examples_ – jsotola Jul 16 '17 at 08:12
  • 1
    @jsotola thanks for sharing this. Honestly, it never crossed my mind that I could find everything I need in the examples. They should have changed its folder name to something like "Usage" so that it would have our attention when we are stuck. – Tehscript Jul 16 '17 at 09:47
  • Hi Tehscript!! You have made me greedy already. In your spare time I suppose you are gonna wanna follow this link: "https://stackoverflow.com/questions/44097296/cant-execute-my-code-without-on-error-resume-next" – SIM Jul 16 '17 at 14:14
  • @SMth80 Please see my answer to your post. Thanks for sharing! – Tehscript Jul 16 '17 at 18:52