Launch the Brave web browser on Linux using selenium JavaScript

0 votes

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

Apr 20, 2022 in Linux Administration by Edureka
• 13,690 points
1,065 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Linux Administration

0 votes
0 answers

Get Selenium to work with Brave browser on Linux

I am trying to get Selenium to ...READ MORE

Apr 14, 2022 in Linux Administration by Soham
• 9,710 points
1,558 views
0 votes
1 answer

To attach a file using mail command on Linux

$ echo | mutt -a syslogs.tar.gz admin@domain.org READ MORE

answered Jun 28, 2019 in Linux Administration by Upasana
• 8,620 points
2,844 views
0 votes
0 answers

What is the equivalent to getch() & getche() in Linux?

I am not able to find the ...READ MORE

Apr 13, 2022 in Linux Administration by Rahul
• 9,680 points
625 views
0 votes
0 answers

On Linux, does the remove command "rm" run in the background?

I am trying to run my test ...READ MORE

Apr 20, 2022 in Linux Administration by Edureka
• 13,690 points
647 views
0 votes
0 answers

What is the difference between ''find .'' and ''find /'' on linux command

I am solving overthewire bandit. I looked ...READ MORE

Apr 20, 2022 in Linux Administration by Edureka
• 13,690 points
435 views
0 votes
0 answers

How can I monitor the thread count of a process on linux?

I would like to monitor the number ...READ MORE

Apr 21, 2022 in Linux Administration by Edureka
• 13,690 points
448 views
0 votes
0 answers

What does "&" at the end of a linux command mean?

I am a system administrator and I ...READ MORE

Apr 21, 2022 in Linux Administration by Edureka
• 13,690 points
581 views
0 votes
0 answers

How can I convert a series of images to a PDF from the command line on linux?

I have a scanning server I wrote ...READ MORE

Apr 21, 2022 in Linux Administration by Edureka
• 13,690 points
579 views
0 votes
0 answers

Excel PERCENTRANK.INC in Javascript

Is there a way to get the ...READ MORE

Mar 23, 2022 in Database by Edureka
• 13,690 points
433 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP