Skip to content
This repository has been archived by the owner on Apr 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #601 from Magenic/feature/WebDriverManagerAsAgent
Browse files Browse the repository at this point in the history
web driver manager as an agent
  • Loading branch information
jason-edstrom authored Oct 28, 2021
2 parents eee2aa5 + b27262d commit 31db5cc
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 150 deletions.
1 change: 0 additions & 1 deletion jmaqs-accessibility/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,5 @@
<SoftAssertScreenshot>Yes</SoftAssertScreenshot>
<SavePagesourceOnFail>Yes</SavePagesourceOnFail>
<ImageFormat>jpeg</ImageFormat>
<WebDriverHintPath>./src/test/resources/drivers</WebDriverHintPath>
</SeleniumMaqs>
</configuration>
32 changes: 6 additions & 26 deletions jmaqs-accessibility/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,11 @@
<groupId>com.magenic.jmaqs.utilities</groupId>
<artifactId>jmaqs-utilities</artifactId>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<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>
<installationDirectory>./src/test/resources/drivers</installationDirectory>
<drivers>
<driver>
<name>chromedriver</name>
<customFileName>chromedriver</customFileName>
<version>${chromedriver.version}</version>
</driver>
</drivers>
</configuration>
</plugin>
</plugins>
</build>
</project>
1 change: 0 additions & 1 deletion jmaqs-cucumber/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<SoftAssertScreenshot>Yes</SoftAssertScreenshot>
<SavePagesourceOnFail>Yes</SavePagesourceOnFail>
<ImageFormat>jpeg</ImageFormat>
<WebDriverHintPath>./src/test/resources/drivers</WebDriverHintPath>
</SeleniumMaqs>

<RemoteSeleniumCapsMaqs>
Expand Down
42 changes: 0 additions & 42 deletions jmaqs-cucumber/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,46 +97,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<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>
<installationDirectory>./src/test/resources/drivers</installationDirectory>
<drivers>
<driver>
<name>chromedriver</name>
<customFileName>chromedriver</customFileName>
<version>${chromedriver.version}</version>
</driver>
<driver>
<name>internetexplorerdriver</name>
<platform>windows</platform>
<customFileName>IEDriverServer</customFileName>
</driver>
<driver>
<name>geckodriver</name>
<customFileName>geckodriver</customFileName>
<version>${geckodriver.version}</version>
</driver>
<driver>
<name>edgedriver</name>
<platform>windows</platform>
<customFileName>MicrosoftWebDriver</customFileName>
<version>${edgedriver.version}</version>
</driver>
</drivers>
</configuration>
</plugin>
</plugins>
</build>
</project>
1 change: 0 additions & 1 deletion jmaqs-selenium/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<SoftAssertScreenshot>Yes</SoftAssertScreenshot>
<SavePagesourceOnFail>Yes</SavePagesourceOnFail>
<ImageFormat>jpeg</ImageFormat>
<WebDriverHintPath>./src/test/resources/drivers</WebDriverHintPath>
</SeleniumMaqs>

<RemoteSeleniumCapsMaqs>
Expand Down
42 changes: 0 additions & 42 deletions jmaqs-selenium/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,46 +78,4 @@
<version>${selenium.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<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>
<installationDirectory>./src/test/resources/drivers</installationDirectory>
<drivers>
<driver>
<name>chromedriver</name>
<customFileName>chromedriver</customFileName>
<version>${chromedriver.version}</version>
</driver>
<driver>
<name>internetexplorerdriver</name>
<platform>windows</platform>
<customFileName>IEDriverServer</customFileName>
</driver>
<driver>
<name>geckodriver</name>
<customFileName>geckodriver</customFileName>
<version>${geckodriver.version}</version>
</driver>
<driver>
<name>edgedriver</name>
<platform>windows</platform>
<customFileName>MicrosoftWebDriver</customFileName>
<version>${edgedriver.version}</version>
</driver>
</drivers>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ public static String getBrowserName() {
* Get the hint path for the web driver.
*
* @return The hint path for the web driver
* @deprecated Removing the find driver logic in favor of using the WebDriverManager to manage binaries
*/
@Deprecated(forRemoval = true)
public static String getDriverHintPath() {
String defaultPath = new java.io.File("Resources").getAbsolutePath();
return Config.getValueForSection(SELENIUM_SECTION, "WebDriverHintPath", defaultPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.magenic.jmaqs.selenium.constants.WebDriverFile;
import com.magenic.jmaqs.selenium.exceptions.DriverNotFoundException;
import com.magenic.jmaqs.selenium.exceptions.WebDriverFactoryException;
import com.magenic.jmaqs.utilities.helper.Config;
import com.magenic.jmaqs.utilities.helper.ConfigSection;
import com.magenic.jmaqs.utilities.helper.StringProcessor;
import java.io.File;
import java.net.URL;
Expand Down Expand Up @@ -47,7 +49,6 @@ private WebDriverFactory() {
* Gets default browser.
*
* @return the default browser
* @throws Exception the exception
*/
public static WebDriver getDefaultBrowser() {
return getBrowserWithDefaultConfiguration(SeleniumConfig.getBrowserType());
Expand Down Expand Up @@ -86,9 +87,9 @@ public static WebDriver getBrowserWithDefaultConfiguration(BrowserType browser)
} catch (Exception e) {

// Log that something went wrong
String message = "Failed to initial web driver because: %s %s"
String message = "Failed to initial web driver because: %s %s"
+ "This likely means your web driver is missing, unsupported or out of date.";
message = StringProcessor.safeFormatter(message, e.getMessage() , System.lineSeparator());
message = StringProcessor.safeFormatter(message, e.getMessage(), System.lineSeparator());

throw new WebDriverFactoryException(message, e);
}
Expand All @@ -110,7 +111,7 @@ public static ChromeOptions getDefaultChromeOptions() {
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-dev-shm-usage");
}

return chromeOptions;
}

Expand Down Expand Up @@ -196,8 +197,6 @@ public static WebDriver getChromeDriver(ChromeOptions chromeOptions) {
* @return the chrome driver
*/
public static WebDriver getChromeDriver(ChromeOptions chromeOptions, String size) {
System.setProperty("webdriver.chrome.driver",
getDriverLocation(WebDriverFile.CHROME.getFileName()) + File.separator + WebDriverFile.CHROME.getFileName());
WebDriver driver = new ChromeDriver(chromeOptions);
setBrowserSize(driver, size);
return driver;
Expand All @@ -210,8 +209,6 @@ public static WebDriver getChromeDriver(ChromeOptions chromeOptions, String size
* @return the headless chrome driver
*/
public static WebDriver getHeadlessChromeDriver(ChromeOptions headlessChromeOptions) {
System.setProperty("webdriver.chrome.driver",
getDriverLocation(WebDriverFile.CHROME.getFileName()) + File.separator + WebDriverFile.CHROME.getFileName());
return new ChromeDriver(headlessChromeOptions);
}

Expand All @@ -223,9 +220,6 @@ public static WebDriver getHeadlessChromeDriver(ChromeOptions headlessChromeOpti
* @return the firefox driver
*/
public static WebDriver getFirefoxDriver(FirefoxOptions firefoxOptions, String size) {
System.setProperty("webdriver.gecko.driver",
getDriverLocation(WebDriverFile.FIREFOX.getFileName()) + File.separator + WebDriverFile.FIREFOX.getFileName());

WebDriver driver = new FirefoxDriver(firefoxOptions);
setBrowserSize(driver, size);

Expand All @@ -240,15 +234,6 @@ public static WebDriver getFirefoxDriver(FirefoxOptions firefoxOptions, String s
* @return the edge driver
*/
public static WebDriver getEdgeDriver(EdgeOptions edgeOptions, String size) {
String driverLocation = getDriverLocation(WebDriverFile.EDGE.getFileName(),
getWindowsEdgeDriverLocation(WebDriverFile.EDGE.getFileName()));

// If we can't find an installed edge driver, look in the normal places
if (driverLocation.isEmpty()) {
driverLocation = getDriverLocation(WebDriverFile.EDGE.getFileName());
}

System.setProperty("webdriver.edge.driver", driverLocation + File.separator + WebDriverFile.EDGE.getFileName());
EdgeDriver driver = new EdgeDriver(edgeOptions);
setBrowserSize(driver, size);
return driver;
Expand All @@ -262,8 +247,6 @@ public static WebDriver getEdgeDriver(EdgeOptions edgeOptions, String size) {
* @return the internet explorer driver
*/
public static WebDriver getInternetExplorerDriver(InternetExplorerOptions internetExplorerOptions, String size) {
System.setProperty("webdriver.ie.driver",
getDriverLocation(WebDriverFile.IE.getFileName()) + File.separator + WebDriverFile.IE.getFileName());
InternetExplorerDriver driver = new InternetExplorerDriver(internetExplorerOptions);
setBrowserSize(driver, size);

Expand Down Expand Up @@ -443,7 +426,9 @@ public static Dimension extractDimensionFromString(String size) {
*
* @param driverFile the driver file
* @return the driver location
* @deprecated Removing the find driver logic in favor of using the WebDriverManager to manage binaries
*/
@Deprecated(forRemoval = true)
public static String getDriverLocation(String driverFile) {
return getDriverLocation(driverFile, "", true);
}
Expand All @@ -454,7 +439,9 @@ public static String getDriverLocation(String driverFile) {
* @param driverFile the driver file
* @param defaultHintPath the default hint path
* @return the driver location
* @deprecated Removing the find driver logic in favor of using the WebDriverManager to manage binaries
*/
@Deprecated(forRemoval = true)
public static String getDriverLocation(String driverFile, String defaultHintPath) {
return getDriverLocation(driverFile, defaultHintPath, true);
}
Expand All @@ -466,7 +453,9 @@ public static String getDriverLocation(String driverFile, String defaultHintPath
* @param defaultHintPath the default hint path
* @param mustExist the must exist
* @return the driver location
* @deprecated Removing the find driver logic in favor of using the WebDriverManager to manage binaries
*/
@Deprecated(forRemoval = true)
public static String getDriverLocation(String driverFile, String defaultHintPath, boolean mustExist) {
// Get the hint path from the config
String hintPath = SeleniumConfig.getDriverHintPath();
Expand Down Expand Up @@ -509,7 +498,9 @@ public static String getDriverLocation(String driverFile, String defaultHintPath
*
* @param file the file
* @return the windows edge driver location
* @deprecated Removing the find driver logic in favor of using the WebDriverManager to manage binaries
*/
@Deprecated(forRemoval = true)
static String getWindowsEdgeDriverLocation(String file) {
String edgeDriverFolder = "Microsoft Web Driver";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void getHubUrl() {
/**
* Driver hint path.
*/
@Test(groups = TestCategories.SELENIUM)
@Test(groups = TestCategories.SELENIUM, enabled = false)
public void getDriverHintPath() {

String path = SeleniumConfig.getDriverHintPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void extractDimensionFromInvalidFormatTest() {
/**
* Tests getting the driver location.
*/
@Test(groups = TestCategories.SELENIUM)
@Test(groups = TestCategories.SELENIUM, enabled = false)
public void getDriverLocationTest() {
String driverLocation = WebDriverFactory.getDriverLocation(WebDriverFile.CHROME.getFileName());
Assert.assertFalse(driverLocation.isEmpty());
Expand All @@ -366,7 +366,7 @@ public void getDriverLocationTest() {
/**
* Tests getting the driver location configuration hint path.
*/
@Test(groups = TestCategories.SELENIUM)
@Test(groups = TestCategories.SELENIUM, enabled = false)
public void getDriverLocationConfigHintPathTest() {
String driverLocation = WebDriverFactory.getDriverLocation(WebDriverFile.CHROME.getFileName());
Assert.assertFalse(driverLocation.isEmpty());
Expand All @@ -377,7 +377,7 @@ public void getDriverLocationConfigHintPathTest() {
/**
* Tests getting the driver location default hint path.
*/
@Test(groups = TestCategories.SELENIUM)
@Test(groups = TestCategories.SELENIUM, enabled = false)
public void getDriverLocationDefaultHintPathTest() {
String driverLocation = WebDriverFactory.getDriverLocation(WebDriverFile.CHROME.getFileName(), "");
Assert.assertFalse(driverLocation.isEmpty());
Expand All @@ -393,7 +393,7 @@ public void getDriverLocationDefaultHintPathTest() {
/**
* Tests getting the driver location test location.
*/
@Test(groups = TestCategories.SELENIUM)
@Test(groups = TestCategories.SELENIUM, enabled = false)
public void getDriverLocationTestLocationTest() {
String driverLocation = WebDriverFactory.getDriverLocation(WebDriverFile.CHROME.getFileName());
Assert.assertFalse(driverLocation.isEmpty());
Expand All @@ -404,7 +404,7 @@ public void getDriverLocationTestLocationTest() {
/**
* Tests getting the driver location and its resource test.
*/
@Test(groups = TestCategories.SELENIUM)
@Test(groups = TestCategories.SELENIUM, enabled = false)
public void getDriverLocationTestResourcesLocationTest() {
String driverLocation = WebDriverFactory.getDriverLocation(WebDriverFile.CHROME.getFileName());
Assert.assertFalse(driverLocation.isEmpty());
Expand All @@ -415,7 +415,7 @@ public void getDriverLocationTestResourcesLocationTest() {
/**
* Tests getting the driver location when it does not exist.
*/
@Test(groups = TestCategories.SELENIUM)
@Test(groups = TestCategories.SELENIUM, enabled = false)
public void getDriverLocationDoesNotExistTest() {
String driverLocation = WebDriverFactory.getDriverLocation("doesNotExist.exe", "", false);
Assert.assertEquals(driverLocation, "");
Expand All @@ -424,7 +424,7 @@ public void getDriverLocationDoesNotExistTest() {
/**
* Tests getting the driver location when it must exist.
*/
@Test(expectedExceptions = RuntimeException.class, groups = TestCategories.SELENIUM)
@Test(expectedExceptions = RuntimeException.class, groups = TestCategories.SELENIUM, enabled = false)
public void getDriverLocationMustExistTest() {
String driverLocation = WebDriverFactory.getDriverLocation("doesNotExist.exe", "", true);
Assert.assertEquals(driverLocation, "");
Expand All @@ -433,7 +433,7 @@ public void getDriverLocationMustExistTest() {
/**
* Tests getting the edge driver location.
*/
@Test(groups = TestCategories.SELENIUM)
@Test(groups = TestCategories.SELENIUM, enabled = false)
public void getWindowsEdgeDriverLocationTest() {
String driverLocation = WebDriverFactory.getWindowsEdgeDriverLocation("testFile");
Assert.assertEquals(driverLocation, "");
Expand Down
Loading

0 comments on commit 31db5cc

Please sign in to comment.