Brave Shield doesnt work when used by selenium

Description of the issue: When i use Brave with Selenium for Automation, the Brave Shield doesn’t work when selenium opens a website, but if I manually click the refresh button, it does work.

How can this issue be reproduced?

  1. Make a basic selenium script that opens a page with ads
  2. Run that script, see that the Shield is “Active” but doesn’t actually remove the ads
  3. Hit the refresh button yourself, see how Shield actually does work this time

Expected result: Shield should work, no matter if selenium or a human opens a page

Brave Version( check About Brave): v1.45.133

Additional Information: I also tried going to a different website manually, same thing. Automated doesn’t work, manual does work.

I specifically wanted to use Brave for this project, since the website im trying to automate has an unholy amount of sketchy pop ups and ads that block the website and even redirect automatically sometimes. So Brave Shield would be such a nice thing to have here. But automating a thing doesn’t make much sense if I have to manually open the site.

1 Like

Hello there @ToasterUwU, please accept my apologies fort this inconvenience. Could you please try opening your main profile in private or guest mode to see if the shields block the ads? If they do, try disabling your extensions to see if this is the cause of the issue.

You can open a Guest Window by going to Main menu --> Open Guest window:

  1. On your computer, open Brave.
  2. At the top right, click Menu → More tools → Extensions.
  3. On to the extension you want to remove, click Remove.
  4. Confirm by clicking Remove.

Let me know if that works.

No need. Selenium doesn’t use the standard profile. It’s like a clean install.

My extensions arent loaded, my bookmarks are not available. Nothing like that.

I’m not talking about shield not working while using the browser as a human. I’m talking about shield not working when selnium (a browser automation framework, available in lots of programming languages) is opening and controlling the Browser.

1 Like

@ToasterUwU on that case, try installing the Beta or Nightly version of Brave to see if the issue persists on those versions.

Be waiting for your response.

1 Like

@Mattches and @JimB1 do either of you have any ideas on this?

Hi, not exactly.

But at its core it sounds like it might be similar to this problem:

If Shields does somehow tie into the Extensions interface, maybe finding where it lives and pointing to its path (like in the Reddit example above) will solve it.

And if not, maybe this will help?

On the other hand this is the opposite of what you’re trying to do, but maybe provides some kind of breadcrumbs:

1 Like

But at its core it sounds like it might be similar to this problem:

Not the same thing at all. That is about how to use extensions that are separately loaded into the selenium instance of the Browser.
My problem is not that im trying to load a extension, but that Brave Shield (built-in adblocker) doesnt block anything.

And since Brave Shield is not a extension anyone downloads, i cant exactly download the crx file and load it like an extension (Just a note, when i encountered this issue i added UBlock Origin at the beggining of the script, like in this reddit example. And that AdBlocker worked well)

And if not, maybe this will help?

Nope, it doesnt. My problem is NOT that i dont know how to use Brave with chromedriver and Selenium. I got it running perfectly fine, its just that Brave Shield is not doing anything. Tells me its on and that it blocked 0 things on this website (The website being a Adblock tester website, opening and using it manually blocks 11 things (I dont have any extra adblockers installed), opening it with selenium blocks 0 things and all ads are showing and are in the way)

On the other hand this is the opposite of what you’re trying to do, but maybe provides some kind of breadcrumbs:

Dont see how a argument that disables the thing that doesnt work, could help me to find the source of the bug that makes it not work. I see why you think that might be an option, but there isnt anything to go off besides a command line option that disables the thing i need to work.

Im gonna test with Beta and Nightly, but i dont think it will help. Will send another message when im done. Spoiler: Stable on Linux has the same problem as Stable on Windows, but not down to the details. On Windows it atleast worked when i manually opened the website in the selenium controlled instance, on linux Shield doesnt work at all, no matter if selenium or my fingers open the website.

Surprising good news. At least on Linux it works on Beta and Nightly, but not on Stable.

So whenever current Beta becomes Stable, it should work just fine.

Thanks for the attempted help, if the Issue for some reason stays around even when Beta becomes Stable, i will make new Thread.

Have a nice Day.

1 Like

Ok, good luck! Hope it works out for you.

@ToasterUwU glad to read that, if you have any other issues or concerns, please let me know or create a new community post so we can further assist you.

Regards :lion:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.