Jump to content

[SOLVED]Disable Notifications in Chrome w/ Webdriver UDF


Recommended Posts

I am once again asking for your experienced assistance. If I open a website that uses notifications I am asked to allow or block them for that website after a few seconds. This notification pops up every time the page gets navigated to, even tho you have clicked on allow for several times. I am explicitly not searching for smth to get rid of "Chrome is being controlled by automated test sw". Instead I am searching for a line of script to disable all notifications by default: like here chrome://settings/content/notifications

This is code should give you an example of what notifications I am talking about:

#include "wd_core.au3"
#include "wd_helper.au3"

Local $sDesiredCapabilities, $sSession, $sID
_WD_Option("Driver", "C:\Program Files (x86)\AutoIt3\chromedriver.exe")
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}'
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "https://webradio.planetradio.de/")
_WD_LoadWait($sSession)

 

Edited by Langmeister
Issue solved
Link to comment
Share on other sites

 

@Danp2 It was my first thought that smth has to be adjusted in the DesiredCapabilities string but if you mean adding it like this, it doesn't work.

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"disable-notifications": {"w3c": true }}}}}'

Returning this:

_WD_CreateSession: {"value":{"error":"invalid argument","message":"invalid argument: cannot parse capability: goog:chromeOptions\nfrom invalid argument: unrecognized chrome option: disable-notifications","stacktrace":"Backtrace: (...)
_WD_CreateSession ==> Webdriver Exception: invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: unrecognized chrome option: disable-notifications

 

Link to comment
Share on other sites

@Danp2 So to speak the mistake sat in front of the pc. Putting it in the right format did all the magic and works fine now with this:

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-notifications"]}}}}'

Thanks for your answers in the past!

Edited by Langmeister
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...