Package org.openqa.selenium.server

Examples of org.openqa.selenium.server.RemoteControlConfiguration


                "number of times.  A simple example of how this could be useful: if you add \"-userContentTransformation https http\" " +
                "then all \"https\" strings in the HTML of the test application will be changed to be \"http\".");
    }

    public static RemoteControlConfiguration parseLauncherOptions(String[] args) {
        RemoteControlConfiguration configuration;
        configuration = new RemoteControlConfiguration();
        configuration.setPort(RemoteControlConfiguration.getDefaultPort());
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if ("-help".equalsIgnoreCase(arg)) {
                usage(null);
                System.exit(1);
            } else if ("-defaultBrowserString".equalsIgnoreCase(arg)) {
                usage("-defaultBrowserString has been renamed -forcedBrowserMode");
            } else if ("-forcedBrowserMode".equalsIgnoreCase(arg)) {
                configuration.setForcedBrowserMode(getArg(args, ++i));
                if (i < args.length) {
                    System.err.println("Warning: -forcedBrowserMode no longer consumes all remaining arguments on line (use -forcedBrowserModeRestOfLine for that)");
                }
            } else if ("-forcedBrowserModeRestOfLine".equalsIgnoreCase(arg)) {
                for (i++; i < args.length; i++) {
                    if (null == configuration.getForcedBrowserMode()) {
                        configuration.setForcedBrowserMode("");
                    } else {
                        configuration.setForcedBrowserMode(configuration.getForcedBrowserMode() + " ");
                    }
                    configuration.setForcedBrowserMode(configuration.getForcedBrowserMode() + args[i]);
                }
            } else if ("-log".equalsIgnoreCase(arg)) {
                configuration.setLogOutFileName(getArg(args, ++i));
            } else if ("-port".equalsIgnoreCase(arg)) {
                configuration.setPort(Integer.parseInt(getArg(args, ++i)));
            } else if ("-multiWindow".equalsIgnoreCase(arg)) {
                configuration.setMultiWindow(true);
            } else if ("-singleWindow".equalsIgnoreCase(arg)) {
                configuration.setMultiWindow(false);
            } else if ("-profilesLocation".equalsIgnoreCase(arg)) {
                File profilesLocation = new File(getArg(args, ++i));
                if (!profilesLocation.exists()) {
                    System.err.println("Specified profile location directory does not exist: " + profilesLocation);
                    System.exit(1);
                }
                configuration.setProfilesLocation(profilesLocation);
            } else if ("-avoidProxy".equalsIgnoreCase(arg)) {
                SeleniumServer.setAvoidProxy(true);
            } else if ("-proxyInjectionMode".equalsIgnoreCase(arg)) {
                configuration.setProxyInjectionModeArg(true);
                // proxyInjectionMode implies singleWindow mode
                configuration.setMultiWindow(false);
            } else if ("-portDriversShouldContact".equalsIgnoreCase(arg)) {
                // to facilitate tcptrace interception of interaction between
                // injected js and the selenium server
                configuration.setPortDriversShouldContact(Integer.parseInt(getArg(args, ++i)));
            } else if ("-noBrowserSessionReuse".equalsIgnoreCase(arg)) {
                configuration.setReuseBrowserSessions(false);
            } else if ("-browserSessionReuse".equalsIgnoreCase(arg)) {
                configuration.setReuseBrowserSessions(true);
            } else if ("-firefoxProfileTemplate".equalsIgnoreCase(arg)) {
                configuration.setFirefoxProfileTemplate(new File(getArg(args, ++i)));
                if (!configuration.getFirefoxProfileTemplate().exists()) {
                    System.err.println("Firefox profile template doesn't exist: " + configuration.getFirefoxProfileTemplate().getAbsolutePath());
                    System.exit(1);
                }
            } else if ("-ensureCleanSession".equalsIgnoreCase(arg)) {
                SeleniumServer.setEnsureCleanSession(true);
            } else if ("-dontInjectRegex".equalsIgnoreCase(arg)) {
                configuration.setDontInjectRegex(getArg(args, ++i));
            } else if ("-browserSideLog".equalsIgnoreCase(arg)) {
                SeleniumServer.setBrowserSideLogEnabled(true);
            } else if ("-debug".equalsIgnoreCase(arg)) {
                SeleniumServer.setDebugMode(true);
            } else if ("-debugURL".equalsIgnoreCase(arg)) {
                configuration.setDebugURL(getArg(args, ++i));
            } else if ("-timeout".equalsIgnoreCase(arg)) {
                configuration.setTimeoutInSeconds(Integer.parseInt(getArg(args, ++i)));
            } else if ("-jettyThreads".equalsIgnoreCase(arg)) {
                int jettyThreadsCount = Integer.parseInt(getArg(args, ++i));

                // Set the number of jetty threads before we construct the instance
                SeleniumServer.setJettyThreads(jettyThreadsCount);
            } else if ("-trustAllSSLCertificates".equalsIgnoreCase(arg)) {
                configuration.setTrustAllSSLCertificates(true);
            } else if ("-userJsInjection".equalsIgnoreCase(arg)) {
                configuration.setUserJSInjection(true);
                if (!InjectionHelper.addUserJsInjectionFile(getArg(args, ++i))) {
                    usage(null);
                    System.exit(1);
                }
            } else if ("-userContentTransformation".equalsIgnoreCase(arg)) {
                if (!InjectionHelper.addUserContentTransformation(getArg(args, ++i), getArg(args, ++i))) {
                    usage(null);
                    System.exit(1);
                }
            } else if ("-userExtensions".equalsIgnoreCase(arg)) {
                configuration.setUserExtensions(new File(getArg(args, ++i)));
                if (!configuration.getUserExtensions().exists()) {
                    System.err.println("User Extensions file doesn't exist: " + configuration.getUserExtensions().getAbsolutePath());
                    System.exit(1);
                }
                if (!"user-extensions.js".equalsIgnoreCase(configuration.getUserExtensions().getName())) {
                    System.err.println("User extensions file MUST be called \"user-extensions.js\": " + configuration.getUserExtensions().getAbsolutePath());
                    System.exit(1);
                }
            } else if ("-selfTest".equalsIgnoreCase(arg)) {
                configuration.setSelfTest(true);
                configuration.setSelfTestDir(new File(getArg(args, ++i)));
                configuration.getSelfTestDir().mkdirs();
            } else if ("-htmlSuite".equalsIgnoreCase(arg)) {
                try {
                    System.setProperty("htmlSuite.browserString", args[++i]);
                    System.setProperty("htmlSuite.startURL", args[++i]);
                    System.setProperty("htmlSuite.suiteFilePath", args[++i]);
                    System.setProperty("htmlSuite.resultFilePath", args[++i]);
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.err.println("Not enough command line arguments for -htmlSuite");
                    System.err.println("-htmlSuite requires you to specify:");
                    System.err.println("* browserString (e.g. \"*firefox\")");
                    System.err.println("* startURL (e.g. \"http://www.google.com\")");
                    System.err.println("* suiteFile (e.g. \"c:\\absolute\\path\\to\\my\\HTMLSuite.html\")");
                    System.err.println("* resultFile (e.g. \"c:\\absolute\\path\\to\\my\\results.html\")");
                    System.exit(1);
                }
                configuration.setHTMLSuite(true);
            } else if ("-interactive".equalsIgnoreCase(arg)) {
                configuration.setTimeoutInSeconds(Integer.MAX_VALUE);
                configuration.setInteractive(true);
            } else if ("-honor-system-proxy".equals(arg)) {
                configuration.setHonorSystemProxy(true);
            } else if (arg.startsWith("-D")) {
                setSystemProperty(arg);
            } else {
                usage("unrecognized argument " + arg);
                System.exit(1);
            }
        }
        if (configuration.userJSInjection() && !configuration.getProxyInjectionModeArg()) {
            System.err.println("User js injection can only be used w/ -proxyInjectionMode");
            System.exit(1);
        }
        if (configuration.getProfilesLocation() != null && configuration.getFirefoxProfileTemplate() != null) {
            System.err.println("Cannot specify both a profileDirectory and a firefoxProfileTemplate");
            System.exit(1);
        }
        return configuration;
    }
View Full Code Here


        }
        return !lock.exists();
    }

    public static void main(String[] args) throws Exception {
        OperaCustomProfileLauncher l = new OperaCustomProfileLauncher(new RemoteControlConfiguration(), "CUSTFF");
        l.launch("http://www.google.com");
        int seconds = 15;
        System.out.println("Killing browser in " + Integer.toString(seconds) + " seconds");
        AsyncExecute.sleepTight(seconds * 1000);
        l.close();
View Full Code Here

                "number of times.  A simple example of how this could be useful: if you add \"-userContentTransformation https http\" " +
                "then all \"https\" strings in the HTML of the test application will be changed to be \"http\".");
    }

    public static RemoteControlConfiguration parseLauncherOptions(String[] args) {
        RemoteControlConfiguration configuration;
        configuration = new RemoteControlConfiguration();
        configuration.setPort(RemoteControlConfiguration.getDefaultPort());
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if ("-help".equalsIgnoreCase(arg)) {
                usage(null);
                System.exit(1);
            } else if ("-defaultBrowserString".equalsIgnoreCase(arg)) {
                usage("-defaultBrowserString has been renamed -forcedBrowserMode");
            } else if ("-forcedBrowserMode".equalsIgnoreCase(arg)) {
                configuration.setForcedBrowserMode(getArg(args, ++i));
                if (i < args.length) {
                    System.err.println("Warning: -forcedBrowserMode no longer consumes all remaining arguments on line (use -forcedBrowserModeRestOfLine for that)");
                }
            } else if ("-forcedBrowserModeRestOfLine".equalsIgnoreCase(arg)) {
                for (i++; i < args.length; i++) {
                    if (null == configuration.getForcedBrowserMode()) {
                        configuration.setForcedBrowserMode("");
                    } else {
                        configuration.setForcedBrowserMode(configuration.getForcedBrowserMode() + " ");
                    }
                    configuration.setForcedBrowserMode(configuration.getForcedBrowserMode() + args[i]);
                }
            } else if ("-log".equalsIgnoreCase(arg)) {
                configuration.setLogOutFileName(getArg(args, ++i));
            } else if ("-port".equalsIgnoreCase(arg)) {
                configuration.setPort(Integer.parseInt(getArg(args, ++i)));
            } else if ("-multiWindow".equalsIgnoreCase(arg)) {
                configuration.setMultiWindow(true);
            } else if ("-singleWindow".equalsIgnoreCase(arg)) {
                configuration.setMultiWindow(false);
            } else if ("-profilesLocation".equalsIgnoreCase(arg)) {
                File profilesLocation = new File(getArg(args, ++i));
                if (!profilesLocation.exists()) {
                    System.err.println("Specified profile location directory does not exist: " + profilesLocation);
                    System.exit(1);
                }
                configuration.setProfilesLocation(profilesLocation);
            } else if ("-avoidProxy".equalsIgnoreCase(arg)) {
                SeleniumServer.setAvoidProxy(true);
            } else if ("-proxyInjectionMode".equalsIgnoreCase(arg)) {
                configuration.setProxyInjectionModeArg(true);
            } else if ("-portDriversShouldContact".equalsIgnoreCase(arg)) {
                // to facilitate tcptrace interception of interaction between
                // injected js and the selenium server
                configuration.setPortDriversShouldContact(Integer.parseInt(getArg(args, ++i)));
            } else if ("-noBrowserSessionReuse".equalsIgnoreCase(arg)) {
                configuration.setReuseBrowserSessions(false);
            } else if ("-browserSessionReuse".equalsIgnoreCase(arg)) {
                configuration.setReuseBrowserSessions(true);
            } else if ("-firefoxProfileTemplate".equalsIgnoreCase(arg)) {
                configuration.setFirefoxProfileTemplate(new File(getArg(args, ++i)));
                if (!configuration.getFirefoxProfileTemplate().exists()) {
                    System.err.println("Firefox profile template doesn't exist: " + configuration.getFirefoxProfileTemplate().getAbsolutePath());
                    System.exit(1);
                }
            } else if ("-ensureCleanSession".equalsIgnoreCase(arg)) {
                SeleniumServer.setEnsureCleanSession(true);
            } else if ("-dontInjectRegex".equalsIgnoreCase(arg)) {
                configuration.setDontInjectRegex(getArg(args, ++i));
            } else if ("-browserSideLog".equalsIgnoreCase(arg)) {
                SeleniumServer.setBrowserSideLogEnabled(true);
            } else if ("-debug".equalsIgnoreCase(arg)) {
                SeleniumServer.setDebugMode(true);
            } else if ("-debugURL".equalsIgnoreCase(arg)) {
                configuration.setDebugURL(getArg(args, ++i));
            } else if ("-timeout".equalsIgnoreCase(arg)) {
                configuration.setTimeoutInSeconds(Integer.parseInt(getArg(args, ++i)));
            } else if ("-jettyThreads".equalsIgnoreCase(arg)) {
                int jettyThreadsCount = Integer.parseInt(getArg(args, ++i));

                // Set the number of jetty threads before we construct the instance
                SeleniumServer.setJettyThreads(jettyThreadsCount);
            } else if ("-trustAllSSLCertificates".equalsIgnoreCase(arg)) {
                configuration.setTrustAllSSLCertificates(true);
            } else if ("-userJsInjection".equalsIgnoreCase(arg)) {
                configuration.setUserJSInjection(true);
                if (!InjectionHelper.addUserJsInjectionFile(getArg(args, ++i))) {
                    usage(null);
                    System.exit(1);
                }
            } else if ("-userContentTransformation".equalsIgnoreCase(arg)) {
                if (!InjectionHelper.addUserContentTransformation(getArg(args, ++i), getArg(args, ++i))) {
                    usage(null);
                    System.exit(1);
                }
            } else if ("-userExtensions".equalsIgnoreCase(arg)) {
                configuration.setUserExtensions(new File(getArg(args, ++i)));
                if (!configuration.getUserExtensions().exists()) {
                    System.err.println("User Extensions file doesn't exist: " + configuration.getUserExtensions().getAbsolutePath());
                    System.exit(1);
                }
                if (!"user-extensions.js".equalsIgnoreCase(configuration.getUserExtensions().getName())) {
                    System.err.println("User extensions file MUST be called \"user-extensions.js\": " + configuration.getUserExtensions().getAbsolutePath());
                    System.exit(1);
                }
            } else if ("-selfTest".equalsIgnoreCase(arg)) {
                configuration.setSelfTest(true);
                configuration.setSelfTestDir(new File(getArg(args, ++i)));
                configuration.getSelfTestDir().mkdirs();
            } else if ("-htmlSuite".equalsIgnoreCase(arg)) {
                try {
                    System.setProperty("htmlSuite.browserString", args[++i]);
                    System.setProperty("htmlSuite.startURL", args[++i]);
                    System.setProperty("htmlSuite.suiteFilePath", args[++i]);
                    System.setProperty("htmlSuite.resultFilePath", args[++i]);
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.err.println("Not enough command line arguments for -htmlSuite");
                    System.err.println("-htmlSuite requires you to specify:");
                    System.err.println("* browserString (e.g. \"*firefox\")");
                    System.err.println("* startURL (e.g. \"http://www.google.com\")");
                    System.err.println("* suiteFile (e.g. \"c:\\absolute\\path\\to\\my\\HTMLSuite.html\")");
                    System.err.println("* resultFile (e.g. \"c:\\absolute\\path\\to\\my\\results.html\")");
                    System.exit(1);
                }
                configuration.setHTMLSuite(true);
            } else if ("-interactive".equalsIgnoreCase(arg)) {
                configuration.setTimeoutInSeconds(Integer.MAX_VALUE);
                configuration.setInteractive(true);
            } else if ("-honor-system-proxy".equals(arg)) {
                configuration.setHonorSystemProxy(true);
            } else if (arg.startsWith("-D")) {
                setSystemProperty(arg);
            } else {
                usage("unrecognized argument " + arg);
                System.exit(1);
            }
        }
        if (configuration.userJSInjection() && !configuration.getProxyInjectionModeArg()) {
            System.err.println("User js injection can only be used w/ -proxyInjectionMode");
            System.exit(1);
        }
        if (configuration.getProfilesLocation() != null && configuration.getFirefoxProfileTemplate() != null) {
            System.err.println("Cannot specify both a profileDirectory and a firefoxProfileTemplate");
            System.exit(1);
        }
        return configuration;
    }
View Full Code Here

            throw new RuntimeException("Unable to start Selenium Server", e);
        }
    }

    private RemoteControlConfiguration configure(SeleniumServerConfiguration configuration) {
        RemoteControlConfiguration rcc = new RemoteControlConfiguration();

        rcc.setAvoidProxy(configuration.isAvoidProxy());
        rcc.setBrowserSideLogEnabled(configuration.isBrowserSideLog());
        rcc.setDebugMode(configuration.isDebug());
        rcc.setDontTouchLogging(configuration.isDontTouchLogging());
        SecurityActions.setProperty("selenium.loglevel", configuration.isDebug() ? "DEBUG" : "INFO");

        rcc.setEnsureCleanSession(configuration.isEnsureCleanSession());

        // set firefox profile
        String ffProfile = configuration.getFirefoxProfileTemplate();
        if (Validate.isNotNullOrEmpty(ffProfile)) {
            Validate.isValidFile(ffProfile, "Firefox profile must point to a readable directory: " + ffProfile);
            rcc.setFirefoxProfileTemplate(new File(ffProfile));
        }

        // force browser type
        String forcedMode = configuration.getForcedBrowserMode();
        if (Validate.isNotNullOrEmpty(forcedMode)) {
            rcc.setForcedBrowserMode(forcedMode);
        }

        rcc.setHonorSystemProxy(configuration.isHonorSystemProxy());

        // log file
        String logFile = configuration.getLogFile();
        if (Validate.isNotNullOrEmpty(logFile)) {
            Validate.isInReadableDirectory(logFile, "Log file cannot be created: " + logFile);
            rcc.setLogOutFile(new File(logFile));
        }

        rcc.setPort(configuration.getPort());

        // set profile location
        String profiles = configuration.getProfilesLocation();
        if (Validate.isNotNullOrEmpty(profiles)) {
            Validate.isValidFile(profiles, "Profiles location must point to a readable directory: " + profiles);
            rcc.setProfilesLocation(new File(profiles));
        }

        rcc.setProxyInjectionModeArg(configuration.isProxyInjectionMode());
        rcc.setReuseBrowserSessions(configuration.isBrowserSessionReuse());
        rcc.setRetryTimeoutInSeconds(configuration.getRetryTimeoutInSeconds());
        rcc.setSingleWindow(configuration.isSingleWindow());
        rcc.setTimeoutInSeconds(configuration.getTimeoutInSeconds());
        rcc.setTrustAllSSLCertificates(configuration.isTrustAllSSLCertificates());

        String userExtensions = configuration.getUserExtensions();
        if (Validate.isNotNullOrEmpty(userExtensions)) {
            Validate.isValidFile(userExtensions, "User extensions must point to a valid file");
            rcc.setUserExtensions(new File(userExtensions));
        }

        return rcc;
    }
View Full Code Here

    private static SeleniumServer seleniumServer;

    @BeforeClass
    public static void setUp() throws Exception {
        System.out.println("*** Starting selenium ... ***");
        RemoteControlConfiguration seleniumConfig = new RemoteControlConfiguration();
        seleniumConfig.setPort(4444);
        seleniumServer = new SeleniumServer(seleniumConfig);
        seleniumServer.start();

        String host = System.getProperty("myParam", "localhost");
        selenium = createSeleniumClient("http://" + host + ":" + "8080/client/");
View Full Code Here

  @Override
  public void setUp() {
    try {
      // Creates custom configuration for the selenium server
      // Tudor Enache
      RemoteControlConfiguration remConCon = new RemoteControlConfiguration();
      if (browser.contains("iexploreproxy")) {
        remConCon.setSingleWindow(true);
      }
      remConCon.setPort(serverPort);
      remConCon.trustAllSSLCertificates();
      remConCon.setAvoidProxy(true);

      // Instantiates selenium server with custom control configuration
      // Tudor Enache
      selServer = new SeleniumServer(remConCon);
      // Instantiates new client with parameters
View Full Code Here

        this.slowResources = slowResources;
    }

    public Selenium getSelenium() {
        try {
            RemoteControlConfiguration conf = new RemoteControlConfiguration();
            int serverPort = getServerPort();
            conf.setPort(serverPort);
            new SeleniumServer(slowResources, conf).start();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return super.getSelenium();
View Full Code Here

      stopSelenium();
    }

    if (server == null && selenium == null) {
      // i.e. only generate these objects when we need to!
      RemoteControlConfiguration config = new RemoteControlConfiguration();
      config.setUserExtensions(new File("bin/selenium/user-extensions.js"));
      server = new SeleniumServer(config);

      server.boot();

      proc = new HttpCommandProcessor("localhost", 4444, runInBrowser, props.getHostToTest());
View Full Code Here

  @BeforeSuite
  public void setupSelenium() throws Exception {

    System.out.println("--- Starting selenium server with debug set to " + debug);

    RemoteControlConfiguration rcc = new RemoteControlConfiguration();
    rcc.setTimeoutInSeconds(seleniumTimeout);
    rcc.setPort(seleniumServerPort);
    //rcc.setMultiWindow(true);
    rcc.setSingleWindow(false);
    PrintStream ps = System.out; // backup
    System.setOut(new PrintStream(new FileOutputStream("logfile"), false, Charsets.UTF_8.name()));
    rcc.setDebugMode(debug);
    server = new SeleniumServer(false, rcc);
    System.setOut(ps); // restore

    server.start();
    System.out.println("--- Started selenium server");
View Full Code Here

        if (timeoutInMs < 0) {
            log.warn("Looks like the timeout overflowed, so resetting it to the maximum.");
            timeoutInMs = Long.MAX_VALUE;
        }
       
        RemoteControlConfiguration configuration = remoteControl.getConfiguration();
        remoteControl.handleHTMLRunnerResults(this);

        String sessionId = Long.toString(System.currentTimeMillis() % 1000000);
        BrowserConfigurationOptions browserOptions = new BrowserConfigurationOptions();
       
        configuration.copySettingsIntoBrowserOptions(browserOptions);
       
        browserOptions.setSingleWindow(!multiWindow);
       
        BrowserLauncher launcher = getBrowserLauncher(browser, sessionId, configuration, browserOptions);
        BrowserSessionInfo sessionInfo = new BrowserSessionInfo(sessionId,
View Full Code Here

TOP

Related Classes of org.openqa.selenium.server.RemoteControlConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.