List of usage examples for org.openqa.selenium.os CommandLine destroy
public int destroy()
From source file:com.atlassian.selenium.browsers.firefox.DisplayAwareFirefoxChromeLauncher.java
License:Apache License
private void populateCustomProfileDirectory(String profilePath) { /*//from w w w .jav a 2 s. co m * The first time we launch Firefox with an empty profile directory, Firefox will launch itself, * populate the profile directory, then kill/relaunch itself, so our process handle goes out of * date. So, the first time we launch Firefox, we'll start it up at an URL that will immediately * shut itself down. */ CommandLine command = prepareCommand(browserInstallation.launcherFilePath(), "-profile", profilePath, "-silent"); command.setDynamicLibraryPath(browserInstallation.libraryPath()); log.info("Preparing Firefox profile..."); command.execute(); try { waitForFullProfileToBeCreated(20 * 1000); } catch (RuntimeException e) { command.destroy(); throw e; } }
From source file:com.mengge.service.local.AppiumServiceBuilder.java
License:Apache License
private File findNodeInCurrentFileSystem() { setUpNPMScript();/*from w w w . ja v a 2s .c o m*/ String instancePath; CommandLine commandLine; try { if (Platform.getCurrent().is(Platform.WINDOWS)) { commandLine = new CommandLine(CMD_EXE, "/C", "npm root -g"); } else { commandLine = new CommandLine(BASH, "-l", npmScript.getAbsolutePath()); } commandLine.execute(); } catch (Throwable e) { throw new RuntimeException(e); } instancePath = (commandLine.getStdOut()).trim(); try { File defaultAppiumNode; if (StringUtils.isBlank(instancePath) || !(defaultAppiumNode = new File(instancePath + File.separator + APPIUM_FOLDER)).exists()) { String errorOutput = commandLine.getStdOut(); throw new InvalidServerInstanceException(ERROR_NODE_NOT_FOUND, new IOException(errorOutput)); } //appium?v1.5 File result; if ((result = new File(defaultAppiumNode, APPIUM_NODE_MASK)).exists()) { return result; } throw new InvalidServerInstanceException(ERROR_NODE_NOT_FOUND, new IOException( "?" + APPIUM_NODE_MASK + "," + defaultAppiumNode + "")); } finally { commandLine.destroy(); } }
From source file:com.mengge.service.local.AppiumServiceBuilder.java
License:Apache License
@Override protected File findDefaultExecutable() { String nodeJSExec = System.getProperty(NODE_PATH); if (StringUtils.isBlank(nodeJSExec)) { nodeJSExec = System.getenv(NODE_PATH); }// w ww .jav a2 s . c o m if (!StringUtils.isBlank(nodeJSExec)) { File result = new File(nodeJSExec); if (result.exists()) { return result; } } CommandLine commandLine; setUpGetNodeJSExecutableScript(); try { if (Platform.getCurrent().is(Platform.WINDOWS)) { commandLine = new CommandLine(NODE + ".exe", getNodeJSExecutable.getAbsolutePath()); } else { commandLine = new CommandLine(NODE, getNodeJSExecutable.getAbsolutePath()); } commandLine.execute(); } catch (Throwable t) { throw new InvalidNodeJSInstance("Node.js!", t); } String filePath = (commandLine.getStdOut()).trim(); try { if (StringUtils.isBlank(filePath) || !new File(filePath).exists()) { String errorOutput = commandLine.getStdOut(); String errorMessage = "Can't get a path to the default Node.js instance"; throw new InvalidNodeJSInstance(errorMessage, new IOException(errorOutput)); } return new File(filePath); } finally { commandLine.destroy(); } }