Run Selenium WebDriver Script on Brave Browser

Aakash Shinghal
2 min readFeb 1, 2022

--

1. Introduction

Brave is a free and open source web browser, based on Chromium Web Browser. In this article, we will learn how we can run our selenium script on brave browser.

To ease our burden, we will use WebDriverManager in our script to manage Webdriver connection between Selenium Script and Brave Browser.

2. Steps to run Selenium Test on Brave Browser

  1. Install any IDEs(IntelliJ, Eclipse, Visual Code)
  2. Install any Java version and set it’s path in environment variable
  3. Create a maven project
  4. Create a pom.xml file in your project(if not existed by default)
  5. Add 2 dependencies in your pom.xml — selenium dependency and WebDriverManager dependency
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>

<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.0.3</version>
</dependency>

</dependencies>

6. Now after adding all the required dependencies, we will create a java file to run our selenium tests on Brave browser. For this, we need to create a link between our Selenium script and brave browser.

7. We will setup chromeDriver to make a connection between browser and Selenium Script

WebDriverManager.chromedriver().setup();

8. Now we will provide an executable path of Brave Browser, else chromedriver will run the tests on Chrome Browser by default. For this, we will use ChromeOptions class, and will use setBinary method to provide Brave browser path.

ChromeOptions chromeOptions = new ChromeOptions().setBinary("/Applications/Brave Browser.app/Contents/MacOS/Brave Browser");

9. Now we will create a webdriver object and provide the chromeoptions we added in previous step.

WebDriver driver = new ChromeDriver(chromeOptions);

10. Now our connectivity is all set. We can now use the webdriver object to run any test.

For reference, you can refer this GitHub code

3. Run our tests in Incognito and Tor Mode

  • To run test in incognito mode, use --incognito in chromeoptions
chromeOptions.addArguments("--incognito");
  • To run test in tor mode, use --tor in chromeoptions
chromeOptions.addArguments("--tor");

4. Sample Code File

Refer below code to have a better understanding of how this is working

I hope you enjoyed reading this article, as much as I enjoyed writing it. If you like this article please let me know! But, more importantly if you disagree with this article please, please, please let me know! I made this with the hope of helping the community so if it is off it defeats the purpose! If you have a suggestion or critique please feel free to drop in any comments.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Aakash Shinghal
Aakash Shinghal

No responses yet

Write a response