/**
   * Looks into the Capabilities, the current $PATH and the System Properties for {@link
   * PhantomJSDriverService#PHANTOMJS_EXECUTABLE_PATH_PROPERTY}.
   *
   * <p>NOTE: If the Capability, the $PATH and the System Property are set, the Capability takes
   * priority over the System Property, that in turn takes priority over the $PATH.
   *
   * @param desiredCapabilities Capabilities in which we will look for the path to PhantomJS
   * @param docsLink The link to the PhantomJS documentation page
   * @param downloadLink The link to the PhantomJS download page
   * @return The driver executable as a {@link File} object
   * @throws IllegalStateException If the executable not found or cannot be executed
   */
  @SuppressWarnings("deprecation")
  protected static File findPhantomJS(
      Capabilities desiredCapabilities, String docsLink, String downloadLink) {
    String phantomjspath = null;
    if (desiredCapabilities != null
        && desiredCapabilities.getCapability(PHANTOMJS_EXECUTABLE_PATH_PROPERTY) != null) {
      phantomjspath =
          (String) desiredCapabilities.getCapability(PHANTOMJS_EXECUTABLE_PATH_PROPERTY);
    } else {
      phantomjspath = CommandLine.find(PHANTOMJS_DEFAULT_EXECUTABLE);
      phantomjspath = System.getProperty(PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantomjspath);
    }

    checkState(
        phantomjspath != null,
        "The path to the driver executable must be set by the %s capability/system property/PATH variable;"
            + " for more information, see %s. "
            + "The latest version can be downloaded from %s",
        PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
        docsLink,
        downloadLink);

    File phantomjs = new File(phantomjspath);
    checkExecutable(phantomjs);
    return phantomjs;
  }
Ejemplo n.º 2
0
 private String findNetworkSetupBin() {
   String defaultPath =
       "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup";
   File defaultLocation = new File(defaultPath);
   if (defaultLocation.exists()) {
     return defaultLocation.getAbsolutePath();
   }
   String networkSetupBin = CommandLine.find("networksetup");
   if (networkSetupBin != null) {
     return networkSetupBin;
   }
   if (defaultLocation.getParentFile().exists()) {
     String[] files = defaultLocation.getParentFile().list();
     String guess =
         chooseSuitableNetworkSetup(
             System.getProperty("os.version"), System.getProperty("os.arch"), files);
     if (guess != null) {
       File guessedLocation = new File(defaultLocation.getParentFile(), guess);
       log.warning(
           "Couldn't find 'networksetup' in expected location; we're taking "
               + "a guess and using "
               + guessedLocation.getAbsolutePath()
               + " instead.  Please create a symlink called 'networksetup' to make "
               + "this warning go away.");
       return guessedLocation.getAbsolutePath();
     }
   }
   throw new MacNetworkSetupException(
       "networksetup couldn't be found in the path!\n"
           + "Please add the directory containing 'networksetup' to your PATH environment\n"
           + "variable.");
 }
  public File asAFile() {
    Optional<String> defaultPath = Optional.fromNullable(CommandLine.find(exeName));

    Optional<String> configuredBinaryPath =
        Optional.fromNullable(environmentVariables.getProperty(exeProperty));
    String exePath = configuredBinaryPath.or(defaultPath).orNull();

    File executableLocation = (exePath != null) ? new File(exePath) : null;

    if (reportMissingBinary) {
      checkForMissingBinaries(executableLocation);
    }
    return executableLocation;
  }
Ejemplo n.º 4
0
  @Parameterized.Parameters
  public static Iterable<String> parameters() {
    ImmutableSortedSet.Builder<String> browsers = ImmutableSortedSet.naturalOrder();

    if (CommandLine.find("chromedriver") != null) {
      browsers.add("*googlechrome");
    }

    if (CommandLine.find("geckodriver") != null) {
      browsers.add("*firefox");
    }

    switch (Platform.getCurrent().family()) {
      case MAC:
        //        browsers.add("*safari");
        break;

      case WINDOWS:
        browsers.add("*MicrosoftEdge");
        break;
    }

    return browsers.build();
  }
Ejemplo n.º 5
0
 private String findScutilBin() {
   String defaultPath = "/usr/sbin/scutil";
   File defaultLocation = new File(defaultPath);
   if (defaultLocation.exists()) {
     return defaultLocation.getAbsolutePath();
   }
   String scutilBin = CommandLine.find("scutil");
   if (scutilBin != null) {
     return scutilBin;
   }
   throw new MacNetworkSetupException(
       "scutil couldn't be found in the path!\n"
           + "Please add the directory containing 'scutil' to your PATH environment\n"
           + "variable.");
 }