## org.openqa.selenium.server.browserlaunchers
Class LauncherUtils

    java.lang.Object
      org.openqa.selenium.server.browserlaunchers.LauncherUtils

    public class LauncherUtils

extends java.lang.Object

Various static utility functions used to launch browsers

Nested Class Summary
`protected static class` `LauncherUtils.ProxySetting`

Constructor Summary
`LauncherUtils()`

Method Summary
`protected static void` `copyDirectory(java.io.File source, java.io.File dest)`
`protected static boolean` `copyDirectory(java.io.File source, java.lang.String suffix, java.io.File dest)` Copies all files matching the suffix to the destination directory.
`protected static void` `copySingleFile(java.io.File sourceFile, java.io.File destFile)`
`protected static void` `copySingleFileWithOverwrite(java.io.File sourceFile, java.io.File destFile, boolean overwrite)`
`protected static java.io.File` `createCustomProfileDir(java.lang.String sessionId)` creates an empty temp directory for managing a browser profile
`static java.io.File` `customProfileDir(java.lang.String sessionId)` Return the name of the custom profile directory for a specific seleniumm session
`static void` `deleteTryTryAgain(java.io.File dir, int tries)` Try several times to recursively delete a directory
`protected static java.io.File` `extractHTAFile(java.io.File dir, int port, java.lang.String resourceFile, java.lang.String outFile)`
`protected static void` `generatePacAndPrefJs(java.io.File customProfileDir, int port, LauncherUtils.ProxySetting proxySetting, java.lang.String homePage, boolean changeMaxConnections, int timeoutInSeconds, boolean avoidProxy)`
`protected static java.lang.String` `getDefaultHTMLSuiteUrl(java.lang.String browserURL, java.lang.String suiteUrl, boolean multiWindow, int serverPort)`
`protected static java.lang.String` `getDefaultRemoteSessionUrl(java.lang.String startURL, java.lang.String sessionId, boolean multiWindow, int serverPort, boolean browserSideLog)`
`protected static java.lang.String` `getQueryString(java.lang.String url)`
`static java.io.InputStream` `getSeleniumResourceAsStream(java.lang.String resourceFile)`
`static boolean` `isScriptFile(java.io.File aFile)`
`protected static java.io.File` `makeProxyPAC(java.io.File parentDir, int port, boolean avoidProxy)` Generate a proxy.pac file, configuring a dynamic proxy for URLs containing "/selenium-server/"
`protected static java.io.File` `makeProxyPAC(java.io.File parentDir, int port, boolean proxySeleniumTrafficOnly, boolean avoidProxy)` Generate a proxy.pac file, configuring a dynamic proxy.
`static java.io.File` `makeProxyPAC(java.io.File parentDir, int port, boolean proxySeleniumTrafficOnly, java.lang.String configuredProxy, java.lang.String proxyPort, java.lang.String nonProxyHosts, boolean avoidProxy)`
`static java.util.Map<java.lang.String,java.lang.String>` `parseDictionary(java.lang.String data, java.util.regex.Pattern pattern)`
`static java.util.Map<java.lang.String,java.lang.String>` `parseDictionary(java.lang.String data, java.util.regex.Pattern pattern, boolean reverse)` Run the specified pattern on each line of the data to extract a dictionary
`static void` `recursivelyDeleteDir(java.io.File customProfileDir)` Delete a directory and all subdirectories
`static java.lang.String` `stripStartURL(java.lang.String url)` Strips the specified URL so it only includes a protocal, hostname and port
`static java.lang.String` `urlEncode(java.lang.String text)` Encodes the text as an URL using UTF-8.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### LauncherUtils

    public LauncherUtils()

Method Detail

### createCustomProfileDir

    protected static java.io.File createCustomProfileDir(java.lang.String sessionId)

  creates an empty temp directory for managing a browser profile

### customProfileDir

    public static java.io.File customProfileDir(java.lang.String sessionId)

  Return the name of the custom profile directory for a specific seleniumm session

  Parameters:
    `sessionId` - Current selenium sesssion id. Cannot be null.
  Returns:
    file path of the custom profile directory for this session.

### recursivelyDeleteDir

    public static void recursivelyDeleteDir(java.io.File customProfileDir)

  Delete a directory and all subdirectories

### deleteTryTryAgain

    public static void deleteTryTryAgain(java.io.File dir,
                                         int tries)

  Try several times to recursively delete a directory

### makeProxyPAC

    protected static java.io.File makeProxyPAC(java.io.File parentDir,
                                               int port,
                                               boolean avoidProxy)
                                        throws java.io.FileNotFoundException

  Generate a proxy.pac file, configuring a dynamic proxy for URLs containing "/selenium-server/"

  Parameters:
    `avoidProxy` - TODO
  Throws:
    `java.io.FileNotFoundException`

### makeProxyPAC

    protected static java.io.File makeProxyPAC(java.io.File parentDir,
                                               int port,
                                               boolean proxySeleniumTrafficOnly,
                                               boolean avoidProxy)
                                        throws java.io.FileNotFoundException

  Generate a proxy.pac file, configuring a dynamic proxy.

  If proxySeleniumTrafficOnly is true, then the proxy applies only to URLs containing "/selenium-server/". Otherwise the proxy applies to all URLs.

  Parameters:
    `avoidProxy` - TODO
  Throws:
    `java.io.FileNotFoundException`

### makeProxyPAC

    public static java.io.File makeProxyPAC(java.io.File parentDir,
                                            int port,
                                            boolean proxySeleniumTrafficOnly,
                                            java.lang.String configuredProxy,
                                            java.lang.String proxyPort,
                                            java.lang.String nonProxyHosts,
                                            boolean avoidProxy)
                                     throws java.io.FileNotFoundException

  Throws:
    `java.io.FileNotFoundException`

### stripStartURL

    public static java.lang.String stripStartURL(java.lang.String url)

  Strips the specified URL so it only includes a protocal, hostname and port

  Throws:
    `java.net.MalformedURLException`

### getQueryString

    protected static java.lang.String getQueryString(java.lang.String url)

### getDefaultHTMLSuiteUrl

    protected static java.lang.String getDefaultHTMLSuiteUrl(java.lang.String browserURL,
                                                             java.lang.String suiteUrl,
                                                             boolean multiWindow,
                                                             int serverPort)

### getDefaultRemoteSessionUrl

    protected static java.lang.String getDefaultRemoteSessionUrl(java.lang.String startURL,
                                                                 java.lang.String sessionId,
                                                                 boolean multiWindow,
                                                                 int serverPort,
                                                                 boolean browserSideLog)

### urlEncode

    public static java.lang.String urlEncode(java.lang.String text)

  Encodes the text as an URL using UTF-8.

  Parameters:
    `text` - the text too encode
  Returns:
    the encoded URI string
  See Also:
    `URLEncoder.encode(java.lang.String, java.lang.String)`

### extractHTAFile

    protected static java.io.File extractHTAFile(java.io.File dir,
                                                 int port,
                                                 java.lang.String resourceFile,
                                                 java.lang.String outFile)

### getSeleniumResourceAsStream

    public static java.io.InputStream getSeleniumResourceAsStream(java.lang.String resourceFile)

### isScriptFile

    public static boolean isScriptFile(java.io.File aFile)

### copySingleFile

    protected static void copySingleFile(java.io.File sourceFile,
                                         java.io.File destFile)

### copySingleFileWithOverwrite

    protected static void copySingleFileWithOverwrite(java.io.File sourceFile,
                                                      java.io.File destFile,
                                                      boolean overwrite)

### copyDirectory

    protected static void copyDirectory(java.io.File source,
                                        java.io.File dest)

### copyDirectory

    protected static boolean copyDirectory(java.io.File source,
                                           java.lang.String suffix,
                                           java.io.File dest)

  Copies all files matching the suffix to the destination directory. If no files match, and the destination directory did not already exist, the destination directory is still created, if possible.

  Parameters:
    `source` - the source directory
    `suffix` - the suffix for all files to be copied.
    `dest` - the destination directory

### generatePacAndPrefJs

    protected static void generatePacAndPrefJs(java.io.File customProfileDir,
                                               int port,
                                               LauncherUtils.ProxySetting proxySetting,
                                               java.lang.String homePage,
                                               boolean changeMaxConnections,
                                               int timeoutInSeconds,
                                               boolean avoidProxy)
                                        throws java.io.FileNotFoundException

  Throws:
    `java.io.FileNotFoundException`

### parseDictionary

    public static java.util.Map<java.lang.String,java.lang.String> parseDictionary(java.lang.String data,
                                                                                   java.util.regex.Pattern pattern,
                                                                                   boolean reverse)

  Run the specified pattern on each line of the data to extract a dictionary

### parseDictionary

    public static java.util.Map<java.lang.String,java.lang.String> parseDictionary(java.lang.String data,
                                                                                   java.util.regex.Pattern pattern)

Copyright © 2009. All Rights Reserved.