Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
Launch the Brave web browser on Linux using selenium & JavaScript

I am trying to setup a hello world app to learn Selenium. I want to write a script that opens the Brave web browser.

I tried a few code scripts online and at Stack overflow and nothing seems to work.

const { Builder } = require("selenium-webdriver")

async function example() {

    let driver = await new Builder().forBrowser("brave").build();
    console.log(driver)
    await driver.get("https://www.youtube.com/");



}


example();

The above script does not recognize brave so I changed forBrowser("brave) to "chrome". It still doesn't work.

I found the following code online that allows me to get the exact directory of the browser I want to launch, but I do not know how to combine it with what I already have.

const chrome = require('selenium-webdriver/chrome');


chrome.setDefaultService(new chrome.ServiceBuilder('/usr/share/applications/google-chrome.desktop').build());

I read the code below at another thread but I am not sure how to launch a browser instance using it.

const chrome = require('selenium-webdriver/chrome')
const chromeOptions = new chrome.Options()

chromeOptions.setChromeBinaryPath('/usr/bin/brave-browser')

EDIT

The code below is my latest attempt at cobbling together methods from around the web to make this work.

const webdriver = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const chromeOptions = new chrome.Options()
chromeOptions.setChromeBinaryPath('/home/wktdev/Desktop/selenium/drivers/chrome/chromedriver')


let driver = new webdriver.Builder()
    .forBrowser('chrome')
    .setChromeOptions(chromeOptions)
    .build();


driver.get('http://example.com');

I get an error saying "Error: The ChromeDriver could not be found on the current PATH. "

I am unsure how to proceed

EDIT I have Chrome launching. Here is what I did:

I updated to the latest Chrome Browser. I downloaded the newest chrome driver that mirrors my version of Chrome here:

https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/

I created a random directory on the desktop such as blah/code and I put the downloaded files there.

I then opened a terminal window and added that directory to my computers path variable like this:

export PATH=$PATH:/some/new/path

I kept the current terminal window open and rand the node.js script and chrome opened.

I now need to know how to change this so that it opens Brave instead

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

As Brave went full-Chromium (starting from version 0.57), to open brave browser you need to set setChromeBinaryPath towards the brave executable as follows:

const webdriver = require('selenium-webdriver');
const chromeOptions = new chrome.Options()
chromeOptions.setChromeBinaryPath('/usr/bin/brave-browser')

let driver = new webdriver.Builder()
    .forBrowser('brave')
    .setChromeOptions(chromeOptions)
    .build();

driver.get('http://example.com');

References

You can find a couple of relevant detailed discussions in:

  • How to use Brave web browser with python, selenium and chromedriver?
  • Use Selenium with Brave Browser pass service object written in python
  • How to initiate Brave browser using Selenium and Python on Windows
about 4 years ago · Santiago Gelvez Report

0

You need to specify the path to the brave executable with setChromeBinaryPath. For example (on Windows):

chromeOptions.setChromeBinaryPath('C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe')

For me, I copied the chromedriver.exe file to my project folder. But you should also be able to place it anywhere in your PATH environment variable.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!