Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

298
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda