Skip to content

Commit

Permalink
[SQUASHME] Change behavior of webdriver dependency download -- disabl…
Browse files Browse the repository at this point in the history
…ed by default for LocalNode
  • Loading branch information
Doug Simmons committed Jul 14, 2015
1 parent bb463bd commit d9c5c93
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 49 deletions.
35 changes: 21 additions & 14 deletions client/src/main/java/com/paypal/selion/configuration/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public static enum ConfigProperty {
* local runs involving the PhantomJS browser.
*/
SELENIUM_PHANTOMJS_PATH("phantomjsPath", "", true),

/**
* The path to the IEDriver executable on the local machine. This parameter is taken into consideration for
* local runs involving the IE browser.
Expand Down Expand Up @@ -590,14 +590,21 @@ public static enum ConfigProperty {
* Default is set to <b>120000</b>
*/
EXECUTION_TIMEOUT("executionTimeout", "120000", false),


/**
* Automatically attempt to download various webdriver dependencies (chromedriver, etc) if they are not
* available. <br>
* Default is set to <b>false</b>
*/
DOWNLOAD_DEPENDENCIES("downloadDependencies", "false", true),

/**
* Timeout for downloading dependencies, in milliseconds.<br>
* <br>
* Used in SeLion to configure the download timeout<br>
* Default is set to <b>600000</b>
*/
DOWNLOAD_TIMEOUT("executionTimeout", "600000", false),
DOWNLOAD_TIMEOUT("downloadTimeout", "600000", true),

/**
* Automatically log pages source code.<br>
Expand All @@ -606,6 +613,17 @@ public static enum ConfigProperty {
*/
LOG_PAGES("logPages", "true", true),

/**
* Maximum duration of a session duration in milliseconds. Session will be forcefully terminated if it takes
* longer.<br>
* The value of this parameter is used as the value of <b>sessionTimeout</b> for ios-driver and selendroid.<br>
* This configuration affects LOCAL EXECUTION RUNS only i.e., when {@link ConfigProperty#SELENIUM_RUN_LOCALLY}
* is set to true.<br>
* The unit is milliseconds.<br>
* Default is set to <b>1800000</b> milliseconds.
*/
MOBILE_DRIVER_SESSION_TIMEOUT("sessionTimeout", "1800000", false),

/**
* Selendroid Server port to use.<br>
* Defaults to the value used by Selendroid (<b>8080</b>)
Expand All @@ -624,17 +642,6 @@ public static enum ConfigProperty {
*/
SELENDROID_SERVER_FORCE_REINSTALL("selendroidServerForceReinstall", "false", true),

/**
* Maximum duration of a session duration in milliseconds. Session will be forcefully terminated if it takes
* longer.<br>
* The value of this parameter is used as the value of <b>sessionTimeout</b> for ios-driver and selendroid.<br>
* This configuration affects LOCAL EXECUTION RUNS only i.e., when {@link ConfigProperty#SELENIUM_RUN_LOCALLY}
* is set to true.<br>
* The unit is milliseconds.<br>
* Default is set to <b>1800000</b> milliseconds.
*/
MOBILE_DRIVER_SESSION_TIMEOUT("sessionTimeout", "1800000", false),

/**
* Timeout that will be used to start Android emulators.<br>
* The value for this parameter is used as the value of <b>timeoutEmulatorStart</b> for selendroid.<br>
Expand Down
25 changes: 13 additions & 12 deletions client/src/main/java/com/paypal/selion/platform/grid/LocalNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ public void shutdown() {
private List<String> determineListOfDownloadsToProcess() {
List<String> list = new ArrayList<>();

if (!Config.getBoolConfigProperty(ConfigProperty.DOWNLOAD_DEPENDENCIES)) {
return list;
}

// for IEDriver
if (SystemUtils.IS_OS_WINDOWS) {
if (!checkForPresenceOf(ConfigProperty.SELENIUM_IEDRIVER_PATH,
SeLionConstants.WEBDRIVER_IE_DRIVER_PROPERTY,
SeLionConstants.IE_DRIVER)) {
SeLionConstants.WEBDRIVER_IE_DRIVER_PROPERTY, SeLionConstants.IE_DRIVER)) {
Config.setConfigProperty(ConfigProperty.SELENIUM_IEDRIVER_PATH, SeLionConstants.SELION_HOME_DIR
+ SeLionConstants.IE_DRIVER);
list.add("iedriver");
Expand All @@ -113,17 +116,15 @@ private List<String> determineListOfDownloadsToProcess() {

// for chromedriver
if (!checkForPresenceOf(ConfigProperty.SELENIUM_CHROMEDRIVER_PATH,
SeLionConstants.WEBDRIVER_CHROME_DRIVER_PROPERTY,
SeLionConstants.CHROME_DRIVER)) {
SeLionConstants.WEBDRIVER_CHROME_DRIVER_PROPERTY, SeLionConstants.CHROME_DRIVER)) {
Config.setConfigProperty(ConfigProperty.SELENIUM_CHROMEDRIVER_PATH, SeLionConstants.SELION_HOME_DIR
+ SeLionConstants.CHROME_DRIVER);
list.add("chromedriver");
}

// for phantomjs
if (!checkForPresenceOf(ConfigProperty.SELENIUM_PHANTOMJS_PATH,
SeLionConstants.WEBDRIVER_PHANTOMJS_DRIVER_PROPERTY,
SeLionConstants.PHANTOMJS_DRIVER)) {
SeLionConstants.WEBDRIVER_PHANTOMJS_DRIVER_PROPERTY, SeLionConstants.PHANTOMJS_DRIVER)) {
Config.setConfigProperty(ConfigProperty.SELENIUM_PHANTOMJS_PATH, SeLionConstants.SELION_HOME_DIR
+ SeLionConstants.PHANTOMJS_DRIVER);
list.add("phantomjs");
Expand All @@ -132,12 +133,12 @@ private List<String> determineListOfDownloadsToProcess() {
return list;
}

/*
* Return true when one of the following conditions is met
*
* 1. ConfigProperty for driverBinary is specified and not blank or null.
* 2. System Property which Selenium uses to find driverBinary is present.
* 3. driverBinary exists in the current working directory OR the PATH
/**
* Return true when one of the following conditions is met <br>
* <br>
* 1. ConfigProperty for driverBinary is specified and not blank or null. <br>
* 2. System Property which Selenium uses to find driverBinary is present. <br>
* 3. driverBinary exists in the current working directory OR the PATH <br>
*/
private boolean checkForPresenceOf(ConfigProperty property, String systemProperty, String driverBinary) {
if (StringUtils.isBlank(Config.getConfigProperty(property)) && System.getProperty(systemProperty) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.os.CommandLine;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

Expand All @@ -32,7 +31,7 @@ class ChromeCapabilitiesBuilder extends DefaultCapabilitiesBuilder {

@Override
public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) {
if (isLocalRun()) {
if (isLocalRun() && StringUtils.isNotBlank(getBinaryPath())) {
System.setProperty(SeLionConstants.WEBDRIVER_CHROME_DRIVER_PROPERTY, getBinaryPath());
}
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
Expand All @@ -53,13 +52,9 @@ public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) {
/*
* Returns the location of chromedriver or "" if it can not be determined.
*/
@SuppressWarnings("deprecation")
private String getBinaryPath() {
String location = System.getProperty(SeLionConstants.WEBDRIVER_CHROME_DRIVER_PROPERTY,
Config.getConfigProperty(ConfigProperty.SELENIUM_CHROMEDRIVER_PATH));
if (StringUtils.isBlank(location)) {
location = CommandLine.find(SeLionConstants.CHROME_DRIVER.replace(".exe", ""));
}
return (location != null) ? location : "";
return location;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.os.CommandLine;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

Expand All @@ -32,7 +31,7 @@ class IECapabilitiesBuilder extends DefaultCapabilitiesBuilder {

@Override
public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) {
if (isLocalRun()) {
if (isLocalRun() && StringUtils.isNotBlank(getBinaryPath())) {
System.setProperty(SeLionConstants.WEBDRIVER_IE_DRIVER_PROPERTY, getBinaryPath());
}
capabilities.setBrowserName(DesiredCapabilities.internetExplorer().getBrowserName());
Expand All @@ -46,13 +45,9 @@ public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) {
/*
* Returns the location of iedriverserver or "" if it can not be determined.
*/
@SuppressWarnings("deprecation")
private String getBinaryPath() {
String location = System.getProperty(SeLionConstants.WEBDRIVER_IE_DRIVER_PROPERTY,
Config.getConfigProperty(ConfigProperty.SELENIUM_IEDRIVER_PATH));
if (StringUtils.isBlank(location)) {
location = CommandLine.find(SeLionConstants.IE_DRIVER.replace(".exe", ""));
}
return (location != null) ? location : "";
return location;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@
package com.paypal.selion.platform.grid.browsercapabilities;

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.os.CommandLine;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;

import com.paypal.selion.SeLionConstants;
import com.paypal.selion.configuration.Config;
import com.paypal.selion.configuration.Config.ConfigProperty;

public class PhantomJSCapabilitiesBuilder extends DefaultCapabilitiesBuilder {

@Override
public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) {
if (isLocalRun()) {
if (isLocalRun() && StringUtils.isNotBlank(getBinaryPath())) {
System.setProperty(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, getBinaryPath());
}
capabilities.setBrowserName(DesiredCapabilities.phantomjs().getBrowserName());
Expand All @@ -45,13 +43,9 @@ public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) {
/*
* Returns the location of phantomjs or "" if it can not be determined.
*/
@SuppressWarnings("deprecation")
private String getBinaryPath() {
String location = System.getProperty(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
Config.getConfigProperty(ConfigProperty.SELENIUM_PHANTOMJS_PATH));
if (StringUtils.isBlank(location)) {
location = CommandLine.find(SeLionConstants.PHANTOMJS_DRIVER.replace(".exe", ""));
}
return (location != null) ? location : "";
return location;
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<modules>
<module>project-bom</module>
<module>common</module>
<module>client</module>
<module>server</module>
<module>client</module>
<module>codegen</module>
<module>archetype</module>
</modules>
Expand Down

0 comments on commit d9c5c93

Please sign in to comment.