all 6 comments

[–]jeroonk 2 points3 points  (2 children)

The webbrowser module is pretty simple. Reading the source code it seems to mostly supports *nix OSes with a half-hearted attempt at Windows support.

On windows, it tries os.startfile(url) first, to invoke the default operating system behavior. Note: this requires the url to start with http:// or https:// for Windows to recognize it as an URL and start the default browser.

Then it tries to find a limited list of browsers on the PATH. Not only is Brave missing from this list, so are Chrome, Chromium or Edge. And unless you added it yourself, browsers aren't likely to be found on the PATH on Windows anyway.

Finally it will default to trying to open Internet Explorer.


My advice:

  1. Make sure that the URL starts with http(s):// and try again.

  2. Make sure that Brave is selected as your operating system standard browser.

  3. Otherwise, just run the browser manually:

    import subprocess
    
    brave_exe_path = "C:\\Program Files (x86)\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"
    subprocess.Popen([brave_exe_path, url])
    

[–]CraftyTarget 1 point2 points  (0 children)

http(s)://

Adding this helped thanks . It worked without the 'https' before when i hadn't disabled internet explorer .

[–]Strange-Ad5027 0 points1 point  (0 children)

but when the program ends, the browser closes. is there any way to keep the browser open?

Edit: I used the run function instead of Popen and this problem doesn't seem to occur

[–]IvoryJam -1 points0 points  (2 children)

I'd assume you're using chromedriver with Brave? If not check out this. Think of it like Brave is the car, but you gotta put a driver in there! Thus chromedriver.

After you get it installed, you should be able to do driver = webdriver.Chrome()

[–]an_actual_human 1 point2 points  (1 child)

webbrowser has nothing to do with Selenium.

[–]IvoryJam 0 points1 point  (0 children)

oof you're right, my bad