List of usage examples for org.openqa.selenium WebDriverException WebDriverException
public WebDriverException(Throwable cause)
From source file:org.uiautomation.ios.server.DOMContext.java
License:Apache License
public String getWindowHandle() { if (windowHandle == null) { throw new WebDriverException("don't know the current window."); }/*from w w w .j av a 2 s . c o m*/ return windowHandle; }
From source file:org.uiautomation.ios.server.instruments.InstrumentsManager.java
License:Apache License
public void startSession(String sessionId, IOSRunningApplication application, Device device, IOSCapabilities capabilities) throws WebDriverException { this.device = device; caps = capabilities;/*from w ww.ja va 2 s. co m*/ deviceType = caps.getDevice(); variation = caps.getDeviceVariation(); sdkVersion = caps.getSDKVersion(); locale = caps.getLocale(); language = caps.getLanguage(); //language = application.getAppleLocaleFromLanguageCode(caps.getLanguage()) // .getAppleLanguagesForPreferencePlist(); boolean timeHack = caps.isTimeHack(); List<String> envtParams = caps.getExtraSwitches(); log.fine("starting session"); try { this.sessionId = sessionId; this.extraEnvtParams = envtParams; output = createTmpOutputFolder(); this.application = application; this.application.setDefaultDevice(deviceType); deviceManager = prepareSimulator(capabilities); if (isWarmupRequired(sdkVersion)) { warmup(); } log.fine("prepare simulator"); if (deviceManager instanceof IOSSimulatorManager) { log.fine("forcing SDK"); ((IOSSimulatorManager) deviceManager).forceDefaultSDK(); log.fine("creating script"); } File uiscript = new ScriptHelper().getScript(port, application.getDotAppAbsolutePath(), sessionId); log.fine("starting instruments"); List<String> instruments = createInstrumentCommand(uiscript.getAbsolutePath()); communicationChannel = new CommunicationChannel(); simulatorProcess = new Command(instruments, true, this); simulatorProcess.setWorkingDirectory(output); simulatorProcess.start(); log.fine("waiting for registration request"); boolean success = communicationChannel.waitForUIScriptToBeStarted(); // appears only in ios6. : Automation Instrument ran into an exception // while trying to run the // script. UIAScriptAgentSignaledException if (!success) { simulatorProcess.forceStop(); killSimulator(); throw new WebDriverException("Instruments crashed."); } if (timeHack) { TimeSpeeder.getInstance().activate(); TimeSpeeder.getInstance().start(); } else { TimeSpeeder.getInstance().desactivate(); } } catch (Exception e) { if (simulatorProcess != null) { simulatorProcess.forceStop(); } killSimulator(); throw new WebDriverException( "error starting instrument for session " + sessionId + ", " + e.getMessage(), e); } finally { log.fine("start session done"); if (deviceManager instanceof IOSSimulatorManager) { log.fine("forcing SDK"); ((IOSSimulatorManager) deviceManager).restoreExiledSDKs(); log.fine("creating script"); } } }
From source file:org.uiautomation.ios.server.IOSDriver.java
License:Apache License
public void addSupportedApplication(IOSApplication application) { boolean added = supportedApplications.add(application); if (!added) { throw new WebDriverException("app already present :" + application.getApplicationPath()); }/*from w ww. j a v a 2 s . com*/ cache.cacheResource(application); }
From source file:org.uiautomation.ios.server.IOSDriver.java
License:Apache License
private static boolean matches(IOSCapabilities applicationCapabilities, IOSCapabilities desiredCapabilities) { if (desiredCapabilities.getBundleName() == null) { throw new WebDriverException("you need to specify the bundle to test."); }/*from w ww.j a va 2 s. co m*/ String desired = desiredCapabilities.getBundleName(); String appName = (String) (applicationCapabilities.getBundleName() != null ? applicationCapabilities.getBundleName() : applicationCapabilities.getCapability("CFBundleDisplayName")); if (!desired.equals(appName)) { return false; } if (desiredCapabilities.getBundleVersion() != null && !desiredCapabilities.getBundleVersion().equals(applicationCapabilities.getBundleVersion())) { return false; } if (desiredCapabilities.getDevice() == null) { throw new WebDriverException("you need to specify the device."); } if (!(applicationCapabilities.getSupportedDevices().contains(desiredCapabilities.getDevice()))) { return false; } // check any extra capability starting with plist_ for (String key : desiredCapabilities.getRawCapabilities().keySet()) { if (key.startsWith(IOSCapabilities.MAGIC_PREFIX)) { String realKey = key.replace(MAGIC_PREFIX, ""); if (!desiredCapabilities.getRawCapabilities().get(key) .equals(applicationCapabilities.getRawCapabilities().get(realKey))) { return false; } } } String l = desiredCapabilities.getLanguage(); if (l != null && !applicationCapabilities.getSupportedLanguages().contains(l)) { throw new SessionNotCreatedException("Language requested, " + l + " ,isn't supported.Supported are : " + applicationCapabilities.getSupportedLanguages()); } String sdk = desiredCapabilities.getSDKVersion(); // TODO freynaud validate for multi SDK /* * if (sdk != null && !sdk.equals(applicationCapabilities.getSDKVersion())) * { throw new IOSAutomationException("Cannot start sdk " + sdk + * ". Run on " + applicationCapabilities.getSDKVersion()); } */ return true; }
From source file:org.uiautomation.ios.server.IOSDriver.java
License:Apache License
public ServerSideSession getSession(String opaqueKey) { for (ServerSideSession session : sessions) { if (session.getSessionId().equals(opaqueKey)) { return session; }//from w w w .j av a 2 s.com } throw new WebDriverException("Cannot find session " + opaqueKey + " on the sesver."); }
From source file:org.uiautomation.ios.server.IOSServer.java
License:Apache License
private void init(IOSServerConfiguration options) { this.options = options; Configuration.BETA_FEATURE = options.isBeta(); Configuration.SIMULATORS_ENABLED = options.hasSimulators(); server = new Server(new InetSocketAddress("0.0.0.0", options.getPort())); ServletContextHandler wd = new ServletContextHandler(server, "/wd/hub", true, false); wd.addServlet(UIAScriptServlet.class, "/uiascriptproxy/*"); wd.addServlet(IOSServlet.class, "/*"); wd.addServlet(ResourceServlet.class, "/resources/*"); wd.addServlet(DeviceServlet.class, "/devices/*"); wd.addServlet(ApplicationsServlet.class, "/applications/*"); wd.addServlet(CapabilitiesServlet.class, "/capabilities/*"); wd.addServlet(ArchiveServlet.class, "/archive/*"); wd.getServletContext().getContextHandler().setMaxFormContentSize(500000); ServletContextHandler statics = new ServletContextHandler(server, "/static", true, false); statics.addServlet(StaticResourceServlet.class, "/*"); ServletContextHandler extra = new ServletContextHandler(server, "/", true, false); extra.addServlet(IDEServlet.class, "/inspector/*"); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[] { wd, statics, extra }); server.setHandler(handlers);/*from w ww . j av a2 s. c o m*/ driver = new IOSServerManager(options); for (String app : this.options.getSupportedApps()) { File appFile = new File(app); if (Configuration.BETA_FEATURE && !appFile.exists()) { // if an url download and extract it try { appFile = ZipUtils.extractAppFromURL(app); } catch (IOException ignore) { log.fine("url: " + app + ": " + ignore); } } if (appFile == null || !appFile.exists()) { throw new WebDriverException(app + " isn't an IOS app."); } driver.addSupportedApplication(APPIOSApplication.createFrom(appFile)); } startFolderMonitor(); StringBuilder b = new StringBuilder(); b.append("\nBeta features enabled ( enabled by -beta flag ): " + Configuration.BETA_FEATURE); b.append("\nSimulator enabled ( enabled by -simulators flag): " + Configuration.SIMULATORS_ENABLED); b.append("\nInspector: http://0.0.0.0:" + options.getPort() + "/inspector/"); b.append("\ntests can access the server at http://0.0.0.0:" + options.getPort() + "/wd/hub"); b.append("\nserver status: http://0.0.0.0:" + options.getPort() + "/wd/hub/status"); b.append("\nConnected devices: http://0.0.0.0:" + options.getPort() + "/wd/hub/devices/all"); b.append("\nApplications: http://0.0.0.0:" + options.getPort() + "/wd/hub/applications/all"); b.append("\nCapabilities: http://0.0.0.0:" + options.getPort() + "/wd/hub/capabilities/all"); b.append("\nMonitoring '" + options.getAppFolderToMonitor() + "' for new applications"); b.append("\nArchived apps " + driver.getApplicationStore().getFolder().getAbsolutePath()); if (Configuration.SIMULATORS_ENABLED) { addSimulatorDetails(b); } b.append("\n\nApplications :\n--------------- \n"); for (APPIOSApplication app : driver.getSupportedApplications()) { b.append("\tCFBundleName=" + (app.getMetadata(IOSCapabilities.BUNDLE_NAME).isEmpty() ? app.getMetadata(IOSCapabilities.BUNDLE_DISPLAY_NAME) : app.getMetadata(IOSCapabilities.BUNDLE_NAME))); String version = app.getMetadata(IOSCapabilities.BUNDLE_VERSION); if (version != null && !version.isEmpty()) { b.append(",CFBundleVersion=" + version); } b.append("\n"); } log.info(b.toString()); startHubRegistration(); wd.setAttribute(DRIVER, driver); extra.setAttribute(DRIVER, driver); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { server.stop(); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:org.uiautomation.ios.server.IOSServerManager.java
License:Apache License
public ServerSideSession getSession(String opaqueKey) { for (ServerSideSession session : sessions) { if (session.getSessionId().equals(opaqueKey)) { if (session.hasCrashed()) { throw new WebDriverException(session.getCrashDetails().toString()); }/*from w ww .j a va 2 s .c om*/ return session; } } throw new WebDriverException("Cannot find session " + opaqueKey + " on the server."); }
From source file:org.uiautomation.ios.server.simulator.IOSSimulatorManager.java
License:Apache License
/** * manages a single instance of the instruments process. Only 1 process can run at a given time. *///from www . j ava 2s . co m public IOSSimulatorManager(IOSCapabilities capabilities) { if (isSimulatorRunning() && !isWarmupRequired()) { throw new WebDriverException("another instance of the simulator is already running."); } this.sdks = ClassicCommands.getInstalledSDKs(); this.desiredSDKVersion = validateSDK(capabilities.getSDKVersion()); xcodeInstall = ClassicCommands.getXCodeInstall(); simulatorSettings = new SimulatorSettings(desiredSDKVersion); bundleId = capabilities.getBundleId(); }
From source file:org.uiautomation.ios.server.simulator.IOSSimulatorManager.java
License:Apache License
public void forceDefaultSDK() { for (String version : sdks) { if (new IOSVersion(version).isGreaterThan(desiredSDKVersion)) { File f = new File(xcodeInstall, "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" + version + ".sdk"); if (!f.exists()) { System.err.println("doesn't exist " + f); } else { File renamed = new File(xcodeInstall, "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/exiledSDKs/iPhoneSimulator" + version + ".sdk"); boolean ok = f.renameTo(renamed); if (!ok) { throw new WebDriverException( "Starting the non default SDK requires some more setup.Failed to move " + f + " to " + renamed + getErrorMessageMoveSDK()); }//from w ww .j av a 2s . c o m } } } }
From source file:org.uiautomation.ios.server.simulator.IOSSimulatorManager.java
License:Apache License
public void restoreExiledSDKs() { File exiled = new File(xcodeInstall, "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/exiledSDKs/"); if (!exiled.exists()) { log.warning(exiled.getAbsolutePath() + " doesn't exist." + getErrorMessageMoveSDK()); return;/*from w w w . j a va 2s . c o m*/ } for (String s : exiled.list()) { File sdk = new File(exiled, s); File original = new File(sdk.getParentFile().getParentFile() + "/SDKs/" + s); boolean ok = sdk.renameTo(original); if (!ok) { throw new WebDriverException( "Error restoring the SDK to its original directory. The SDK will be missing in xcode."); } } }