Auto turn off JavaScript Chrome C#

133 views
Skip to first unread message

Karl Farley

unread,
Mar 15, 2023, 5:48:14 AM3/15/23
to Selenium Users
Hi.

I'm trying to automatically turn off JavaScript (project requirement) when running Selenium WebDriver tests using the C# bindings.

I'm using Selenium 4 so there is no longer any DesiredCapability classes/methods that I can use e.g. I can no longer do the following:

ChromeOptions.AddAdditionalCapability("profile.managed_default_content_settings.javascript", 2);

Also, the following throws an unrecognised argument exception.

ChromeOptions.AddArguments(" --disable-javascript  ");

Seems like Java and Python Selenium bindings might still provide the relevant classes/methods to auto turn off JavaScript but not C#.

Can anyone help with this please - it has to be a C# solution?

Thanks,

Karl.
Reply all
Reply to author
Forward
0 new messages