Java源码示例:org.openqa.selenium.os.ExecutableFinder
示例1
protected void addWebDriverExeBrowse() {
String value = BrowserConfig.instance().getValue(getBrowserName(), "webdriver-exe-path");
String def = new ExecutableFinder().find(getWebDriverExecutableName());
wdExeField = new TextField();
if (def != null)
wdExeField.setPromptText(def);
if (value != null)
wdExeField.setText(value);
browseWDExeButton = FXUIUtils.createButton("browse", "Browse WebDriver Executable", true, "Browse");
FileSelectionHandler fileSelectionHandler = new FileSelectionHandler(this, null, null, browseWDExeButton,
"Select WebDriver executable");
fileSelectionHandler.setMode(FileSelectionHandler.FILE_CHOOSER);
browseWDExeButton.setOnAction(fileSelectionHandler);
basicPane.addFormField("WebDriver Executable:", wdExeField, browseWDExeButton);
}
示例2
/**
*
* @param exeName Name of the executable file to look for in PATH
* @param exeProperty Name of a system property that specifies the path to the executable file
* @param exeDocs The link to the driver documentation page
* @param exeDownload The link to the driver download page
*
* @return The driver executable as a {@link File} object
* @throws IllegalStateException If the executable not found or cannot be executed
*/
protected static File findExecutable(
String exeName,
String exeProperty,
String exeDocs,
String exeDownload) {
String defaultPath = new ExecutableFinder().find(exeName);
String exePath = System.getProperty(exeProperty, defaultPath);
Require.state("The path to the driver executable", exePath).nonNull(
"The path to the driver executable must be set by the %s system property;"
+ " for more information, see %s. "
+ "The latest version can be downloaded from %s",
exeProperty, exeDocs, exeDownload);
File exe = new File(exePath);
checkExecutable(exe);
return exe;
}
示例3
@Before
public void detectBrowser() {
browser = System.getProperty("selenium.browser", "*googlechrome");
switch (browser) {
case "*firefox":
assumeNotNull(new ExecutableFinder().find("geckodriver"));
break;
case "*googlechrome":
assumeNotNull(new ExecutableFinder().find("chromedriver"));
break;
default:
assumeFalse("No known driver able to be found", false);
}
}
示例4
private static Path sign(Path toSign) throws IOException {
LOG.info("Signing " + toSign);
// Ideally, we'd use BouncyCastle for this, but for now brute force by assuming
// the gpg binary is on the path
String path = new ExecutableFinder().find("gpg");
if (path == null) {
throw new IllegalStateException("Unable to find gpg for signing artifacts");
}
Path dir = Files.createTempDirectory("maven-sign");
Path file = dir.resolve(toSign.getFileName() + ".asc");
CommandLine gpg = new CommandLine(
"gpg", "--use-agent", "--armor", "--detach-sign", "--no-tty",
"-o", file.toAbsolutePath().toString(), toSign.toAbsolutePath().toString());
gpg.execute();
if (!gpg.isSuccessful()) {
throw new IllegalStateException("Unable to sign: " + toSign + "\n" + gpg.getStdOut());
}
// Verify the signature
CommandLine verify = new CommandLine(
"gpg", "--verify", "--verbose", "--verbose",
file.toAbsolutePath().toString(), toSign.toAbsolutePath().toString());
verify.execute();
if (!verify.isSuccessful()) {
throw new IllegalStateException("Unable to verify signature of " + toSign + "\n" + gpg.getStdOut());
}
return file;
}
示例5
private static File findBinary(String name, String errMsg) {
return validatePath(new ExecutableFinder().find(name), errMsg);
}