List of usage examples for org.openqa.selenium.remote DriverCommand QUIT
String QUIT
To view the source code for org.openqa.selenium.remote DriverCommand QUIT.
Click Source Link
From source file:com.mengge.remote.AppiumCommandExecutor.java
License:Apache License
@Override public Response execute(Command command) throws IOException, WebDriverException { if (DriverCommand.NEW_SESSION.equals(command.getName()) && service != null) { service.start();// w ww . j a v a2s . co m } try { return super.execute(command); } catch (Throwable t) { Throwable rootCause = Throwables.getRootCause(t); if (rootCause instanceof ConnectException && rootCause.getMessage().contains("Connection refused") && service != null) { if (service.isRunning()) { throw new WebDriverException("The session is closed!", t); } if (!service.isRunning()) { throw new WebDriverException("The appium server has accidentally died!", t); } } Throwables.propagateIfPossible(t); throw new WebDriverException(t); } finally { if (DriverCommand.QUIT.equals(command.getName()) && service != null) { service.stop(); } } }
From source file:com.qmetry.qaf.automation.support.perfecto.PerfectoDriverListener.java
License:Open Source License
@Override public void beforeCommand(QAFExtendedWebDriver driver, CommandTracker commandTracker) { if (commandTracker.getCommand().equalsIgnoreCase(DriverCommand.QUIT)) { try {/*from w w w. j ava 2 s. c o m*/ String appName = (String) driver.getCapabilities().getCapability("applicationName"); if (StringUtil.isNotBlank(appName) && StringUtil .isBlank((String) driver.getCapabilities().getCapability("eclipseExecutionId"))) { try { // open application command String command = "mobile:application:close"; // open application driver.executeScript(command, ImmutableMap.of("name", appName)); } catch (Error e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } driver.close(); } catch (Exception e) { // ignore } } }
From source file:com.qmetry.qaf.automation.ui.webdriver.LiveIsExtendedWebDriver.java
License:Open Source License
@Override protected Response execute(String driverCommand, Map<String, ?> parameters) { if (driverCommand.equalsIgnoreCase(DriverCommand.QUIT)) { return new Response(); }// ww w . j av a 2s. c om return super.execute(driverCommand, parameters); }
From source file:com.quantum.listerners.PerfectoDriverListener.java
License:Open Source License
@Override public void beforeCommand(QAFExtendedWebDriver driver, CommandTracker commandTracker) { if (commandTracker.getCommand().equalsIgnoreCase(DriverCommand.QUIT)) { try {/*from ww w . j a v a 2 s . c o m*/ String appName = (String) driver.getCapabilities().getCapability("applicationName"); if (StringUtil.isNotBlank(appName) && StringUtil .isBlank((String) driver.getCapabilities().getCapability("eclipseExecutionId"))) { try { PerfectoQAFSteps.closeApplication(appName); } catch (Exception e) { } } driver.close(); } catch (Exception e) { // ignore } } }
From source file:galen.api.server.GalenCommandExecutor.java
License:Apache License
/** * Executes the command received over the Thrift interface inside an instance of RemoteWebDriver. * @param sessionId WebDriver SessionId. * @param commandName Command name.//ww w. java2 s . c om * @param params Command params. * @return an instance of {@link org.openqa.selenium.remote.Response} * @throws TException */ @Override public Response execute(String sessionId, String commandName, String params) throws TException { Map<String, Object> paramsAsMap = fromJsonToStringObjectMap(params); if (commandName.equals(DriverCommand.NEW_SESSION)) { try { log.info("Setting up new WebDriver session"); HashMap<String, Object> hashMap = extractDesiredCapabilities(paramsAsMap); WebDriver driver = new RemoteWebDriver(new URL(remoteServerAddress), new DesiredCapabilities(hashMap)); DriversPool.get().set(driver); return createSessionInitSuccessResponse(driver); } catch (MalformedURLException e) { log.error("Provided URL is malformed " + remoteServerAddress); return createSessionInitFailureResponse("Provided URL is malformed " + remoteServerAddress); } catch (UnreachableBrowserException e) { log.error("Could not reach browser at URL " + remoteServerAddress + " check remote server is running."); return createSessionInitFailureResponse("Could not reach browser at URL " + remoteServerAddress + " check remote server is running."); } catch (WebDriverException e) { throw new RemoteWebDriverException(e.getMessage()); } } Command driverCommand = new Command(new SessionId(sessionId), handleCommandNameExceptions(commandName), paramsAsMap); try { log.info(format("Executing command %s for sessionId %s", commandName, sessionId)); WebDriver driver = DriversPool.get().getBySessionId(sessionId); org.openqa.selenium.remote.Response response = null; if (driver instanceof RemoteWebDriver) { response = ((RemoteWebDriver) driver).getCommandExecutor().execute(driverCommand); } if (response == null) { return null; } else { if (commandName.equals(DriverCommand.QUIT)) { DriversPool.get().removeDriverBySessionId(sessionId); } ThriftValueWrapper valueWrapper = new ThriftValueWrapper(response.getValue()); return new Response(valueWrapper.getValue(), valueWrapper.getContainedValues(), response.getSessionId(), response.getStatus(), response.getState()); } } catch (IOException ioe) { log.error(format("IOException while executing command %s: %s", commandName, ioe.toString())); } catch (WebDriverException wex) { log.error(format("WebDriverException while executing command %s: + %s", commandName, wex.toString())); throw new RemoteWebDriverException(wex.getMessage()); } return null; }
From source file:io.appium.java_client.remote.AppiumCommandExecutor.java
License:Apache License
@Override public Response execute(Command command) throws IOException, WebDriverException { if (DriverCommand.NEW_SESSION.equals(command.getName()) && service != null) { service.start();/*from w ww .ja v a 2 s. c om*/ } try { return super.execute(command); } catch (Throwable t) { Throwable rootCause = Throwables.getRootCause(t); if (rootCause instanceof ConnectException && rootCause.getMessage().contains("Connection refused") && service != null) { if (service.isRunning()) throw new WebDriverException("The session is closed!", t); if (!service.isRunning()) throw new WebDriverException("The appium server has accidentally died!", t); } Throwables.propagateIfPossible(t); throw new WebDriverException(t); } finally { if (DriverCommand.QUIT.equals(command.getName()) && service != null) { service.stop(); } } }