• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CommandLine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openqa.selenium.os.CommandLine的典型用法代码示例。如果您正苦于以下问题:Java CommandLine类的具体用法?Java CommandLine怎么用?Java CommandLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CommandLine类属于org.openqa.selenium.os包,在下文中一共展示了CommandLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: executeCommand

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public void executeCommand() throws Throwable {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_COMMAND_LINE).setMainClass("-version");
    final CommandLine commandLine = profile.getCommandLine();
    AssertJUnit.assertNotNull(commandLine);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    commandLine.copyOutputTo(baos);
    commandLine.executeAsync();
    new Wait("Waiting till the command is complete") {
        @Override public boolean until() {
            return !commandLine.isRunning();
        }
    };
    BufferedReader reader = new BufferedReader(new StringReader(new String(baos.toByteArray())));
    String line = reader.readLine();
    while (line != null && !line.contains("java version")) {
        line = reader.readLine();
    }
    AssertJUnit.assertTrue(line.contains("java version"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:JavaProfileTest.java


示例2: executeWSCommand

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public void executeWSCommand() throws Throwable {
    if (OS.isFamilyWindows()) {
        throw new SkipException("Test not valid for Windows");
    }
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_WEBSTART).addWSArgument("-verbose").addVMArgument("-Dx.y.z=hello");
    final CommandLine commandLine = profile.getCommandLine();
    AssertJUnit.assertNotNull(commandLine);
    AssertJUnit.assertTrue(commandLine.toString().contains("-javaagent:"));
    AssertJUnit.assertTrue(commandLine.toString().contains("-verbose"));
    AssertJUnit.assertTrue(commandLine.toString().contains("-Dx.y.z=hello"));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    commandLine.copyOutputTo(baos);
    commandLine.executeAsync();
    new Wait("Waiting till the command is complete") {
        @Override public boolean until() {
            return !commandLine.isRunning();
        }
    };
    BufferedReader reader = new BufferedReader(new StringReader(new String(baos.toByteArray())));
    String line = reader.readLine();
    while (line != null && !line.contains("Web Start")) {
        line = reader.readLine();
    }
    AssertJUnit.assertTrue(line.contains("Web Start"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:26,代码来源:JavaProfileTest.java


示例3: launchAllure

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public static void launchAllure(boolean showDialog, String... args) {
	if (showDialog)
		WaitMessageDialog.setVisible(true, "Generating reports");
	List<String> vmArgs = getVMArgs();
	Iterator<String> iterator = vmArgs.iterator();
	while (iterator.hasNext()) {
		String next = iterator.next();
		if (next.contains("-javaagent") || next.contains("-D")) {
			if (!next.contains("-Dallure")) {
				iterator.remove();
			}
		}
	}
	vmArgs.add("-classpath");
	vmArgs.add(System.getProperty("java.class.path"));
	String property = System.getProperty(Constants.PROP_TMS_PATTERN);
	if (property != null && !"".equals(property)) {
		vmArgs.add("-D" + Constants.PROP_TMS_PATTERN + "=" + property);
	}
	property = System.getProperty(Constants.PROP_ISSUE_PATTERN);
	if (property != null && !"".equals(property)) {
		vmArgs.add("-D" + Constants.PROP_ISSUE_PATTERN + "=" + property);
	}
	ArrayList<String> newArgs = new ArrayList<String>();
	newArgs.add(getJavaCommand());
	newArgs.addAll(vmArgs);
	newArgs.add(AllureMain.class.getName());
	newArgs.addAll(new ArrayList<String>(Arrays.asList(args)));
	CommandLine command = new CommandLine(newArgs.toArray(new String[newArgs.size()]));
	command.copyOutputTo(System.out);
	Logger.getLogger(TestRunner.class.getName()).info("Launching: " + command);
	command.execute();
	if (showDialog)
		WaitMessageDialog.setVisible(false);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:36,代码来源:AllureUtils.java


示例4: start

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public void start() {
    if (profile.isEmbedded()) {
        if (server != null) {
            return;
        }
        int port = getAddressOfRemoteServer().getPort();
        server = new EmbeddedServer(profile);
        try {
            server.start(port);
        } catch (IOException e) {
            throw new WebDriverException("Unable to start the server on port " + port, e);
        }
    } else {
        final CommandLine command = profile.getCommandLine();
        Logger.getLogger(JavaDriverCommandExecutor.class.getName()).info("Executing: " + command);
        command.copyOutputTo(profile.getOutputStream());
        command.executeAsync();
        new Wait() {
            @Override public boolean until() {
                return isConnected() || !profile.isJavaWebStart() && !Boolean.getBoolean(MARATHON_APPLICATION_DONT_MONITOR)
                        && !command.isRunning();
            }
        }.wait("Timedout waiting for the server to start", Long.getLong("marathon.application.wait", Wait.DEFAULT_TIMEOUT * 5));
        if (!isConnected() && !command.isRunning()) {
            throw new WebDriverException("Unable to launch the application. command = " + command);
        }

    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:30,代码来源:JavaDriverCommandExecutor.java


示例5: getJavaCommandLineWithClasspath

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public void getJavaCommandLineWithClasspath() throws Throwable {
    File f = new File(".").getCanonicalFile();
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_COMMAND_LINE).addClassPath(f);
    CommandLine commandLine = profile.getCommandLine();
    AssertJUnit.assertTrue(commandLine.toString().contains("-cp"));
    AssertJUnit.assertTrue(commandLine.toString().contains(f.getAbsolutePath()));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:8,代码来源:JavaProfileTest.java


示例6: getWsCommandWithJNLP

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public void getWsCommandWithJNLP() throws Throwable {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_WEBSTART).addWSArgument("-verbose").addVMArgument("-Dx.y.z=hello");
    profile.setJNLPPath(new File("SwingSet3.jnlp").getAbsolutePath());
    final CommandLine commandLine = profile.getCommandLine();
    AssertJUnit.assertNotNull(commandLine);
    AssertJUnit.assertTrue(commandLine.toString().contains("-javaagent:"));
    AssertJUnit.assertTrue(commandLine.toString().contains("-verbose"));
    AssertJUnit.assertTrue(commandLine.toString().contains("-Dx.y.z=hello"));
    AssertJUnit.assertTrue(commandLine.toString().contains("SwingSet3.jnlp"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:JavaProfileTest.java


示例7: checkForArguments

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public void checkForArguments() throws Throwable {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_WEBSTART);
    File f = findFile();
    profile.setJNLPPath(f.getAbsolutePath());
    profile.setStartWindowTitle("SwingSet3");
    profile.addVMArgument("-Dhello=world");
    CommandLine commandLine = profile.getCommandLine();
    System.out.println(commandLine);
    AssertJUnit.assertTrue(commandLine.toString().matches(".*JAVA_TOOL_OPTIONS=.*-Dhello=world.*"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:LaunchWebStartTest.java


示例8: checkGivenExecutableIsUsed

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public void checkGivenExecutableIsUsed() throws Throwable {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_WEBSTART);
    profile.setJavaCommand("java");
    File f = findFile();
    profile.setJNLPPath(f.getAbsolutePath());
    profile.setStartWindowTitle("SwingSet3");
    profile.addVMArgument("-Dhello=world");
    CommandLine commandLine = profile.getCommandLine();
    String exec = findExecutableOnPath("java");
    AssertJUnit.assertTrue(commandLine.toString(), commandLine.toString().contains(exec));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:LaunchWebStartTest.java


示例9: main

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_WEBSTART);
    File f = findFile();
    profile.setJNLPPath(f.getAbsolutePath());
    profile.setStartWindowTitle("SwingSet3");
    CommandLine commandLine = profile.getCommandLine();
    commandLine.copyOutputTo(System.err);
    System.out.println(commandLine);
    commandLine.execute();

}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:LaunchWebStartTest.java


示例10: checkForArguments

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public void checkForArguments() throws Throwable {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_APPLET);
    File f = findFile();
    profile.setAppletURL(f.getAbsolutePath());
    profile.setStartWindowTitle("Applet Viewer: SwingSet3Init.class");
    profile.addVMArgument("-Dhello=world");
    CommandLine commandLine = profile.getCommandLine();
    AssertJUnit.assertTrue(commandLine.toString().contains("-Dhello=world"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:10,代码来源:LaunchAppletTest.java


示例11: checkGivenExecutableIsUsed

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public void checkGivenExecutableIsUsed() throws Throwable {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_APPLET);
    File f = findFile();
    profile.setAppletURL(f.getAbsolutePath());
    profile.setStartWindowTitle("Applet Viewer: SwingSet3Init.class");
    String actual = "";
    if (OS.isFamilyWindows()) {
        String path = System.getenv("Path");
        String[] split = path.split(";");
        File file = new File(split[0]);
        File[] listFiles = file.listFiles();
        if (listFiles != null) {
            for (File listFile : listFiles) {
                if (listFile.getName().contains(".exe")) {
                    profile.setJavaCommand(listFile.getAbsolutePath());
                    actual = listFile.getAbsolutePath();
                    break;
                }
            }
        }
    } else {
        actual = "ls";
        profile.setJavaCommand(actual);
    }
    CommandLine commandLine = profile.getCommandLine();
    AssertJUnit.assertTrue(commandLine.toString().contains(actual));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:28,代码来源:LaunchAppletTest.java


示例12: start

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
/**
 * 启动appium服务端
 *
 *
 * @throws AppiumServerHasNotBeenStartedLocallyException
 * 如果在产生子进程中发生错误,则抛此异常
 *
 * @see #stop()
 */
public void start() throws AppiumServerHasNotBeenStartedLocallyException {
    lock.lock();
    try {
        if (isRunning()) {
            return;
        }

        try {
            process = new CommandLine(this.nodeJSExec.getCanonicalPath(),
                nodeJSArgs.toArray(new String[] {}));
            process.setEnvironmentVariables(nodeJSEnvironment);
            process.copyOutputTo(stream);
            process.executeAsync();
            ping(startupTimeout, timeUnit);
        } catch (Throwable e) {
            destroyProcess();
            String msgTxt = "本地appium服务尚未启动. "
                + "Node.js路径: " + this.nodeJSExec.getAbsolutePath()
                + " 参数: " + nodeJSArgs.toString() + " " + "\n";
            if (process != null) {
                String processStream = process.getStdOut();
                if (!StringUtils.isBlank(processStream)) {
                    msgTxt = msgTxt + "Process output: " + processStream + "\n";
                }
            }

            throw new AppiumServerHasNotBeenStartedLocallyException(msgTxt, e);
        }
    } finally {
        lock.unlock();
    }
}
 
开发者ID:JoeUtt,项目名称:menggeqa,代码行数:42,代码来源:AppiumDriverLocalService.java


示例13: getJavaCommandLine

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
public void getJavaCommandLine() {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_COMMAND_LINE).addVMArgument("-version");
    CommandLine commandLine = profile.getCommandLine();
    AssertJUnit.assertNotNull(commandLine);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:6,代码来源:JavaProfileTest.java


示例14: killPID

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
private static void killPID(String processID) {
    new CommandLine("taskkill", "/f", "/t", "/pid", processID).execute();
}
 
开发者ID:epam,项目名称:JDI,代码行数:4,代码来源:TestNGBase.java


示例15: executeCommand

import org.openqa.selenium.os.CommandLine; //导入依赖的package包/类
private static void executeCommand(String commandName, String... args) {
    CommandLine cmd = new CommandLine(commandName, args);
    cmd.execute();
}
 
开发者ID:ggasoftware,项目名称:gga-selenium-framework,代码行数:5,代码来源:WebDriverUtils.java



注:本文中的org.openqa.selenium.os.CommandLine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Expression类代码示例发布时间:2022-05-23
下一篇:
Java AnnotationModelEvent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap