List of usage examples for org.openqa.selenium.remote HttpCommandExecutor HttpCommandExecutor
public HttpCommandExecutor(URL addressOfRemoteServer)
From source file:com.google.android.testing.nativedriver.client.AndroidNativeDriverBuilder.java
License:Apache License
public AndroidNativeDriverBuilder withServer(URL url) { this.commandExecutor = new HttpCommandExecutor(Preconditions.checkNotNull(url)); return this; }
From source file:com.lohika.alp.selenium.AlpWebDriverFactory.java
License:Open Source License
public static WebDriver getDriver(String SeleniumUrl, DesiredCapabilities capabilities) throws MalformedURLException { Logger alpSeleniumLogger = Logger.getLogger("com.lohika.alp.selenium"); if (alpSeleniumLogger.getLevel() == null) alpSeleniumLogger.setLevel(Level.DEBUG); URL remoteAddress = new URL(SeleniumUrl); CommandExecutor commandExecutor = new HttpCommandExecutor(remoteAddress); WebDriver driver;// w ww . j a va 2 s. c o m // Set name of WebDriver to be shown in log String name = capabilities.getBrowserName(); // Configure capabilities for webdriver to use js error catcher (only FF support now) WebDriverConfigurator webDriverConfigurator = new WebDriverConfigurator(name); capabilities = webDriverConfigurator.configure(capabilities); // Create remote WebDriver instance driver = new RemoteWebDriverTakeScreenshotFix(commandExecutor, capabilities); // Set factory for log objects LogElementsSeleniumFactory logObjectsFactory = new LogElementsSeleniumFactoryJAXB(); // Register WebDriver event listener to handle exceptions // TODO initialize factory separately LogElementsSeleniumFactory elementsFactory = new LogElementsSeleniumFactoryJAXB(); WebDriverEventListener listener = new LoggingWebDriverListener(elementsFactory); driver = new EventFiringWebDriver(driver); ((EventFiringWebDriver) driver).register(listener); // Wrap WebDriver with logging facility // FIXME Do not use 'instanceof' in logging decorators // Otherwise LoggingWebDriver can be only the last in the decorators chain driver = new LoggingWebDriver(driver, name, logObjectsFactory); return driver; }
From source file:org.auraframework.test.AdaptiveWebElementDriver.java
License:Apache License
public AdaptiveWebElementDriver(URL remoteAddress, Capabilities desiredCapabilities, Capabilities requiredCapabilities) { this(new HttpCommandExecutor(remoteAddress), desiredCapabilities, requiredCapabilities); }
From source file:org.auraframework.test.AdaptiveWebElementDriver.java
License:Apache License
public AdaptiveWebElementDriver(URL remoteAddress, Capabilities desiredCapabilities) { this(new HttpCommandExecutor(remoteAddress), desiredCapabilities, null); }
From source file:org.jboss.arquillian.ajocado2.reusable.ReusableRemoteWebDriver.java
License:Apache License
/** * Reuses browser session using sessionId and desiredCapabilities as fully-initialized {@link Capabilities} object from the * previous {@link RemoteWebDriver} session. * /* w w w. j a v a 2 s . c om*/ * @param remoteAddress address of the remote Selenium Server hub * @param desiredCapabilities fully-initialized capabilities returned from previous {@link RemoteWebDriver} session * @param sessionId sessionId from previous {@link RemoteWebDriver} session */ public ReusableRemoteWebDriver(URL remoteAddress, Capabilities desiredCapabilities, SessionId sessionId) throws UnableReuseSessionException { super(); setCommandExecutor(new HttpCommandExecutor(remoteAddress)); startClient(); reuseSession(sessionId, desiredCapabilities); checkReusability(); }
From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ReusableRemoteWebDriver.java
License:Apache License
private ReusableRemoteWebDriver(URL remoteAddress, Capabilities desiredCapabilities, SessionId sessionId) throws UnableReuseSessionException { super();//w w w . ja v a 2 s . c o m setCommandExecutor(new HttpCommandExecutor(remoteAddress)); startClient(); reuseSession(sessionId, desiredCapabilities); checkReusability(); }
From source file:org.uiautomation.ios.client.uiamodels.impl.AttachRemoteIOSDriver.java
License:Apache License
public AttachRemoteIOSDriver(URL url, SessionId session) { super(url, null); setCommandExecutor(new HttpCommandExecutor(url)); setSessionId(session.toString()); }
From source file:org.uiautomation.ios.client.uiamodels.impl.AttachRemoteUIADriver.java
License:Apache License
public AttachRemoteUIADriver(URL url, SessionId session) { super(url, null); setCommandExecutor(new HttpCommandExecutor(url)); setSessionId(session.toString()); }
From source file:phantomjs.PhantomJSDriver.java
License:Apache License
/** * In case this instance was required to handle the life-cycle of the PhantomJS process, that starts here. * Otherwise this is a "transparent" method. * * @param desiredCapabilities/* w w w . ja va 2s.co m*/ * @param requiredCapabilities * @throws WebDriverException */ @Override protected void startSession(Capabilities desiredCapabilities, Capabilities requiredCapabilities) throws WebDriverException { // Will launch a PhantomJS WebDriver process ONLY if this driver is not already using an external one if (!useExternalPhantomJS) { // Read PhantomJS executable and JS Driver path from the capabilities String executablePath = (String) desiredCapabilities.getCapability(CAPABILITY_PHANTOMSJS_EXEC_PATH); String driverPath = (String) desiredCapabilities.getCapability(CAPABILITY_PHANTOMJS_DRIVER_PATH); // Throw WebDriverException in case any of the previous two was not provided if (executablePath == null || driverPath == null || !new File(executablePath).exists() || !new File(driverPath).exists()) { throw new WebDriverException( "PhantomJSDriver: Path to PhantomJS Executable or Driver not provided/invalid"); } // Read the Proxy configuration Proxy proxy = (Proxy) desiredCapabilities.getCapability(CapabilityType.PROXY); // Prepare the parameters to pass to the PhantomJS executable on the command line String proxyParams = ""; if (proxy != null) { switch (proxy.getProxyType()) { case MANUAL: if (!proxy.getHttpProxy().isEmpty()) { //< HTTP proxy log(getSessionId(), "Reading Proxy Configuration", "Manual, HTTP", When.BEFORE); proxyParams = String.format("--proxy-type=http --proxy=%s", proxy.getHttpProxy()); } else if (!proxy.getSocksProxy().isEmpty()) { //< SOCKS5 proxy log(getSessionId(), "Reading Proxy Configuration", "Manual, SOCKS5", When.BEFORE); proxyParams = String.format("--proxy-type=socks5 --proxy=%s --proxy-auth=%s:%s", proxy.getSocksProxy(), proxy.getSocksUsername(), proxy.getSocksPassword()); } else { // TODO Other type of proxy not supported yet by PhantomJS log(getSessionId(), "Reading Proxy Configuration", "Manual, NOT SUPPORTED", When.BEFORE); } break; case PAC: // TODO Not supported yet by PhantomJS log(getSessionId(), "Reading Proxy Configuration", "PAC, NOT SUPPORTED", When.BEFORE); break; case SYSTEM: log(getSessionId(), "Reading Proxy Configuration", "SYSTEM", When.BEFORE); proxyParams = "--proxy-type=system"; break; case AUTODETECT: // TODO Not supported yet by PhantomJS log(getSessionId(), "Reading Proxy Configuration", "AUTODETECT, NOT SUPPORTED", When.BEFORE); break; case DIRECT: log(getSessionId(), "Reading Proxy Configuration", "DIRECT", When.BEFORE); proxyParams = "--proxy-type=none"; default: log(getSessionId(), "Reading Proxy Configuration", "NONE", When.BEFORE); proxyParams = ""; break; } } // Find a free port to launch PhantomJS WebDriver on String phantomJSPortStr = Integer.toString(PortProber.findFreePort()); log(getSessionId(), "Looking for a free port for PhantomJS WebDriver", phantomJSPortStr, When.AFTER); log(getSessionId(), "About to launch PhantomJS WebDriver", null, When.BEFORE); try { // Launch PhantomJS and wait for first output on console before proceeding phantomJSProcess = Runtime.getRuntime().exec(new String[] { executablePath, //< path to PhantomJS executable proxyParams, //< command line parameters for Proxy configuration driverPath, //< path to the PhantomJS Driver phantomJSPortStr //< port on which the Driver should listen on }); final BufferedReader reader = new BufferedReader( new InputStreamReader(phantomJSProcess.getInputStream())); while (reader.readLine() == null) { /* wait here for some output: once it prints, it's ready to work */ } useExternalPhantomJS = false; // PhantomJS is ready to serve. // Setting the HTTP Command Executor that this RemoteWebDriver will use setCommandExecutor(new HttpCommandExecutor(new URL("http://localhost:" + phantomJSPortStr))); } catch (IOException ioe) { // Log exception & Cleanup log(getSessionId(), null, ioe, When.EXCEPTION); stopClient(); throw new WebDriverException("PhantomJSDriver: " + ioe.getMessage(), ioe); } log(getSessionId(), "PhantomJS WebDriver ready", null, When.AFTER); } // We are ready to let the RemoteDriver do its job from here super.startSession(desiredCapabilities, requiredCapabilities); }