Skip to content

Commit

Permalink
#41 Use WebDriverManager to manage the Webdriver
Browse files Browse the repository at this point in the history
- Remove webdriverextensions-maven-plugin
- Add dependency webdrivermanager

-> Use WebDriverManager to manage the WebDriver binary files:
Automatically downloads the latest driver (to
~/.m2/repository/webdriver) and sets the path to the driver binary

--> WebDriverManager is more popular than
webdriverextensions-maven-plugin, easier to use and independent of Maven
--> webdriverextensions-maven-plugin does not seem to get updates
anymore
  • Loading branch information
helkv committed Feb 3, 2020
1 parent 1dcd24b commit fa23e5b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 76 deletions.
80 changes: 6 additions & 74 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,6 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.github.webdriverextensions</groupId>
<artifactId>webdriverextensions-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>install-drivers</goal>
</goals>
</execution>
</executions>
<configuration>
<drivers>
<driver>
<name>geckodriver</name>
<platform>windows</platform>
<bit>64</bit>
<version>0.26.0</version>
<url>https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-win64.zip</url>
</driver>
<driver>
<name>geckodriver</name>
<platform>linux</platform>
<bit>64</bit>
<version>0.26.0</version>
<url>https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz</url>
</driver>
<driver>
<name>chromedriver</name>
<platform>windows</platform>
<bit>32</bit>
<version>77.0.3865.40</version>
<url>https://chromedriver.storage.googleapis.com/77.0.3865.40/chromedriver_win32.zip</url>
</driver>
<driver>
<name>chromedriver</name>
<platform>linux</platform>
<bit>64</bit>
<version>77.0.3865.40</version>
<url>https://chromedriver.storage.googleapis.com/77.0.3865.40/chromedriver_linux64.zip</url>
</driver>
</drivers>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand All @@ -80,10 +36,6 @@
<!-- <suiteXmlFile>res/testng_edmond_chrome.xml</suiteXmlFile> -->
</suiteXmlFiles>
<forkMode>once</forkMode>
<systemPropertyVariables>
<webdriver.gecko.driver>${project.basedir}/drivers/${geckodriver.binary.name}</webdriver.gecko.driver>
<webdriver.chrome.driver>${project.basedir}/drivers/${chromedriver.binary.name}</webdriver.chrome.driver>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
Expand All @@ -95,6 +47,12 @@
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>

<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.8.1</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -116,32 +74,6 @@
</dependencies>

<profiles>
<profile>
<id>windows_os</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<geckodriver.binary.name>geckodriver-windows-64bit.exe</geckodriver.binary.name>
<chromedriver.binary.name>chromedriver-windows-32bit.exe</chromedriver.binary.name>
</properties>
</profile>

<profile>
<id>unix_os</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<geckodriver.binary.name>geckodriver-linux-64bit</geckodriver.binary.name>
<chromedriver.binary.name>chromedriver-linux-64bit</chromedriver.binary.name>
</properties>
</profile>

<profile>
<id>imeji_gui_testing_passwords</id>
<properties>
Expand Down
12 changes: 10 additions & 2 deletions src/test/base/SeleniumTestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;

import io.github.bonigarcia.wdm.WebDriverManager;

public class SeleniumTestSuite {

private static WebDriver driver;
Expand Down Expand Up @@ -114,8 +116,11 @@ private static void setDriver(String browserType) {

private static WebDriver initFirefoxDriver() {
log4j.info("Launching Firefox browser...");

WebDriverManager.firefoxdriver().setup();

// The system property webdriver.gecko.driver must be set to the
// webdriver-executable-file -> this is done by Maven!
// webdriver-executable-file -> this is done by the WebDriverManager!
log4j.info("Found system property webdriver.gecko.driver: " + System.getProperty("webdriver.gecko.driver"));

FirefoxOptions options = new FirefoxOptions();
Expand All @@ -141,8 +146,11 @@ private static WebDriver initFirefoxDriver() {

private static WebDriver initChromeDriver() {
log4j.info("Launching Chrome browser...");

WebDriverManager.chromedriver().setup();

// The system property webdriver.chrome.driver must be set to the
// webdriver-executable-file -> this is done by Maven!
// webdriver-executable-file -> this is done by the WebDriverManager!
log4j.info("Found system property webdriver.chrome.driver: " + System.getProperty("webdriver.chrome.driver"));

ChromeOptions options = new ChromeOptions();
Expand Down

0 comments on commit fa23e5b

Please sign in to comment.