本文整理汇总了Java中org.openqa.selenium.net.PortProber类的典型用法代码示例。如果您正苦于以下问题:Java PortProber类的具体用法?Java PortProber怎么用?Java PortProber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PortProber类属于org.openqa.selenium.net包,在下文中一共展示了PortProber类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startServer
import org.openqa.selenium.net.PortProber; //导入依赖的package包/类
@Override
public int startServer(TestSession session) throws ServerException {
port = PortProber.findFreePort();
String[] args = getArgs(port);
if (LOG.isLoggable(Level.INFO)) {
LOG.info(String.format("Spawning a Selenium server using the arguments [%s]", Arrays.toString(args)));
}
ProcessBuilder pb = new ProcessBuilder(getArgs(port));
try {
this.process = pb.start();
return port;
} catch (Exception e) {
throw new ServerException(e.getMessage(), e);
}
}
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:16,代码来源:JvmBasedSeleniumServer.java
示例2: getCheckedAvailablePort
import org.openqa.selenium.net.PortProber; //导入依赖的package包/类
private int getCheckedAvailablePort(int configuredPort, String serverProtocol) {
int actualPort;
if (isAvailablePort(configuredPort)) {
actualPort = configuredPort;
} else {
actualPort = PortProber.findFreePort();
LOG.debug("Configured or default port = " + configuredPort + " for" + serverProtocol.toUpperCase() + " server is not available!!!");
LOG.debug("Founded free port for " + serverProtocol.toUpperCase() + " is " + actualPort);
}
return actualPort;
}
开发者ID:tapack,项目名称:satisfy,代码行数:12,代码来源:FakeEmailServerRunnerImpl.java
示例3: start
import org.openqa.selenium.net.PortProber; //导入依赖的package包/类
public static HttpServer start(String pathToServe) throws IOException {
HttpServer httpServer = HttpServer.create();
httpServer.createContext("/", createHttpExchange(pathToServe));
httpServer.bind(new InetSocketAddress("localhost", PortProber.findFreePort()), 0);
httpServer.start();
return httpServer;
}
开发者ID:lkwg82,项目名称:de.lgohlke.selenium-webdriver,代码行数:8,代码来源:HttpServerFromResource.java
示例4: beforeEachTest
import org.openqa.selenium.net.PortProber; //导入依赖的package包/类
@Before
public void beforeEachTest() throws IOException {
httpServer = HttpServer.create();
httpServer.createContext("/webdriverTest", httpExchange -> {
String response = "Welcome Real's HowTo test page";
httpExchange.sendResponseHeaders(200, response.length());
OutputStream os = httpExchange.getResponseBody();
os.write(response.getBytes());
os.close();
});
httpServer.bind(new InetSocketAddress("localhost", PortProber.findFreePort()), 0);
httpServer.start();
}
开发者ID:lkwg82,项目名称:de.lgohlke.selenium-webdriver,代码行数:14,代码来源:ChromeDriverServiceFactoryIT.java
示例5: checkOutUnusedPort
import org.openqa.selenium.net.PortProber; //导入依赖的package包/类
/**
* Checks out the next available unused port. Callers should send the returned port
* back to {@link #releaseUnusedPort(int)} when it's no longer being used.
*
* @throws NoSuchElementException if no unused port is available.
*/
public synchronized int checkOutUnusedPort() {
if (availablePorts == null) {
return PortProber.findFreePort();
} else if (availablePorts.isEmpty()) {
// All available ports are checked out.
throw new NoSuchElementException("No unused ports are available");
}
return availablePorts.pop();
}
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:16,代码来源:TestPortFinder.java
示例6: foo
import org.openqa.selenium.net.PortProber; //导入依赖的package包/类
private static void foo() throws Exception {
boolean debug = Boolean.parseBoolean(System.getProperty("debug", "false"));
String dockerHost = String.format("http://%s:%d", CENTOS, 2375);
DockerClient docker = null;
try {
docker = DefaultDockerClient.builder()
.uri(dockerHost).build();
Info info = docker.info();
System.err.println("Information : " + info);
if (debug) {
docker.pull(SELENIUM_STANDALONE_CHROME, new LoggingBuildHandler());
} else {
docker.pull(SELENIUM_STANDALONE_CHROME);
}
final ImageInfo imageInfo = docker.inspectImage(SELENIUM_STANDALONE_CHROME);
System.err.println("Information : " + imageInfo);
// Bind container ports to host ports
// final String[] ports = {Integer.toString(PortProber.findFreePort())};
final String[] ports = {"4444"};
final Map<String, List<PortBinding>> portBindings = new HashMap<>();
for (String port : ports) {
List<PortBinding> hostPorts = new ArrayList<>();
hostPorts.add(PortBinding.of("0.0.0.0", PortProber.findFreePort()));
portBindings.put(port, hostPorts);
}
// // Bind container port 443 to an automatically allocated available host port.
// List<PortBinding> randomPort = new ArrayList<>();
// randomPort.add(PortBinding.randomPort("0.0.0.0"));
// portBindings.put("443", randomPort);
System.err.println("Printing the port mappings : " + portBindings);
final HostConfig hostConfig = HostConfig.builder().portBindings(portBindings).build();
final ContainerConfig containerConfig = ContainerConfig.builder()
.hostConfig(hostConfig)
.image(SELENIUM_STANDALONE_CHROME).exposedPorts(ports)
.build();
final ContainerCreation creation = docker.createContainer(containerConfig);
final String id = creation.id();
// Inspect container
final ContainerInfo containerInfo = docker.inspectContainer(id);
System.err.println("Container Information " + containerInfo);
String msg = "Checking to see if the container with id [" + id + "] and name [" +
containerInfo.name() + "]...";
System.err.println(msg);
if (! containerInfo.state().running()) {
// Start container
docker.startContainer(id);
System.err.println(containerInfo.name() + " is now running.");
} else {
System.err.println(containerInfo.name() + " was already running.");
}
System.err.println("Lets wait here !!!");
} finally {
if (docker != null) {
docker.close();
}
}
}
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:64,代码来源:DockerSample.java
示例7: createServer
import org.openqa.selenium.net.PortProber; //导入依赖的package包/类
private static void createServer() {
serverPort = PortProber.findFreePort();
localIP = new NetworkUtils().getPrivateLocalAddress();
initServer();
}
开发者ID:mach6,项目名称:oscon-aus-2016,代码行数:6,代码来源:TestServerUtils.java
示例8: before
import org.openqa.selenium.net.PortProber; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
port=PortProber.findFreePort();
log.info("found free port: {}",port);
}
开发者ID:lkwg82,项目名称:de.lgohlke.selenium-webdriver,代码行数:6,代码来源:FreeportProber.java
示例9: getDefaultFirefoxProfile
import org.openqa.selenium.net.PortProber; //导入依赖的package包/类
public FirefoxProfile getDefaultFirefoxProfile() {
FirefoxProfile profile = new FirefoxProfile();
boolean generated = false;
int newPort = 7055;
int i = 100;
while (!generated && (--i > 0)) {
newPort = PortProber.findFreePort();
generated = firefoxPorts.add(newPort);
}
if (!generated) {
newPort = 7055;
}
if (firefoxPorts.size() > 20) {
firefoxPorts.remove(0);
}
LOGGER.debug(firefoxPorts);
profile.setPreference(FirefoxProfile.PORT_PREFERENCE, newPort);
LOGGER.debug("FireFox profile will use '" + newPort + "' port number.");
profile.setPreference("dom.max_chrome_script_run_time", 0);
profile.setPreference("dom.max_script_run_time", 0);
if (Configuration.getBoolean(Configuration.Parameter.AUTO_DOWNLOAD) && !(Configuration.isNull(Configuration.Parameter.AUTO_DOWNLOAD_APPS)
|| "".equals(Configuration.get(Configuration.Parameter.AUTO_DOWNLOAD_APPS))))
{
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", ReportContext.getArtifactsFolder().getAbsolutePath());
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", Configuration.get(Configuration.Parameter.AUTO_DOWNLOAD_APPS));
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.saveLinkAsFilenameTimeout", 1);
profile.setPreference("pdfjs.disabled", true);
profile.setPreference("plugin.scan.plid.all", false);
profile.setPreference("plugin.scan.Acrobat", "99.0");
}
else if (Configuration.getBoolean(Configuration.Parameter.AUTO_DOWNLOAD) && Configuration.isNull(Configuration.Parameter.AUTO_DOWNLOAD_APPS)
|| "".equals(Configuration.get(Configuration.Parameter.AUTO_DOWNLOAD_APPS)))
{
LOGGER.warn(
"If you want to enable auto-download for FF please specify '" + Configuration.Parameter.AUTO_DOWNLOAD_APPS.getKey() + "' param");
}
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
return profile;
}
开发者ID:qaprosoft,项目名称:carina,代码行数:49,代码来源:FirefoxCapabilities.java
注:本文中的org.openqa.selenium.net.PortProber类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论