A maven template for Selenium 4 that has the latest dependencies so that you can just check out and start writing tests in four easy steps. If you like what you see have a look at my Selenium book Mastering Selenium Webdriver.
cd Selenium-Maven-Template
(Or whatever folder you cloned it into)mvn clean verify
All dependencies should now be downloaded and the example google cheese test will have run successfully in headless mode (Assuming you have Firefox installed in the default location)
mvn clean verify -P-selenium-tests
Yes you can specify which browser to use by using one of the following on the command line:
-Dbrowser=firefox
-Dbrowser=chrome
-Dbrowser=ie
-Dbrowser=edge
-Dbrowser=opera
-Dbrowser=brave
If you want to toggle the use of chrome or firefox in headless mode set the headless flag (by default the headless flag is set to true)
-Dheadless=true
-Dheadless=false
You don't need to worry about downloading the IEDriverServer, EdgeDriver, ChromeDriver , OperaChromiumDriver, or GeckoDriver binaries, this project will do that for you automatically.
You can specify a grid to connect to where you can choose your browser, browser version and platform:
-Dremote=true
-DseleniumGridURL=http://{username}:{accessKey}@ondemand.saucelabs.com:80/wd/hub
-Dplatform=xp
-Dbrowser=firefox
-DbrowserVersion=44
You can even specify multiple threads (you can do it on a grid as well!):
-Dthreads=2
You can also specify a proxy to use
-DproxyEnabled=true
-DproxyHost=localhost
-DproxyPort=8080
-DproxyUsername=fred
-DproxyPassword=Password123
If the tests fail screenshots will be saved in ${project.basedir}/target/screenshots
If you need to force a binary overwrite you can do:
-Doverwrite.binaries=true
You have probably got outdated driver binaries, by default they are not overwritten if they already exist to speed things up. You have two options:
mvn clean verify -Doverwrite.binaries=true
selenium_standalone_binaries
folder in your resources directoryCurrently, Brave seems to be a bit flaky when running in headless mode, I would suggest running with -Dheadless=false
You probably don't have the brave binary installed in one of the default locations that this codebase is expecting. That's OK though, you can specify it by seeting the following system property:
-DbraveBinaryLocation=/path/to/brave-browser